小编lea*_*456的帖子

Github 问题:Git 推送到 master 分支,而不是 main 并且无法合并两者

每次我在 github 上创建存储库并推送我的文件时,它都会创建两个分支,主分支和主分支。所有更改都转到主分支,当我转到“比较和拉取请求”时,它说没有什么可比较的,因此无法推送到主分支。

这些是我采取的步骤: 转到 github,创建一个存储库。转到我的文件夹并运行git init, git add ., git commit -m "first commit", git remote add origin my@repository,git push -u origin master 现在我知道了,我需要创建一个主分支,所以我也运行git checkout -b main它运行成功,但是当我运行git push --set-upstream origin main它时会抛出一个错误:

 ! [rejected]          main -> main (non-fast-forward)
error: failed to push some refs to 'git@github.com:myuser/myrepo.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git …
Run Code Online (Sandbox Code Playgroud)

git github branching-and-merging

0
推荐指数
2
解决办法
954
查看次数

标签 统计

branching-and-merging ×1

git ×1

github ×1