【问题标题】:how to push my project to github in a default branch, or merge two github branches remotely?如何在默认分支中将我的项目推送到 github,或远程合并两个 github 分支?
【发布时间】:2022-11-12 05:55:11
【问题描述】:

我通过angular 创建了一个editor project,我想将它推入githup,我按照以下步骤操作(我执行了以下git 命令):

git init
git add .
git commit -m "push editor project"

所有这些都在branch 本地master 中。 我创建了一个github account。 我在分支 main 中创建了一个“editorangular”存储库。 我执行了命令:

git remote add origin master git@github.com:najib132/editorangular.git
git remote -v

(它给了我两个链接:

origin git@github.com:najib132/editorangular.git (fetch)
origin git@github.com:najib132/editorangular.git (push)

) 当我执行命令时

git push -u origin main

它给了我错误:

$ git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to 'github.com:najib132/editorangular.git'

然后我执行命令:git push -u origin master 它创建了一个remote 分支master。 在 github 分支 main 它不是来自我的项目,当我将 branch 更改为 master 时,我找到了我的 project。 所以我想merge这两个远程分支mastermain之间,或者直接将我的项目推送到默认分支main

【问题讨论】:

    标签: git github


    【解决方案1】:

    你有两个选择:

    • 本地合并推送
    • 远程拉取请求

    选项1:本地合并并推送

    在主分支上的命令行上,您可以执行以下命令:

    git checkout main
    

    如果说主分支不存在或其他原因失败,只需添加-b 开关

    git checkout -b main
    

    然后向上推

    git push -u origin main
    

    选项 2:在远程创建拉取请求。

    按照此页面上的说明进行操作 - https://github.com/najib132/editorangular/compare/main...master

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-24
      • 2013-03-31
      • 1970-01-01
      • 2020-01-05
      • 2011-06-12
      • 2012-11-23
      • 2018-06-26
      相关资源
      最近更新 更多