git pull 说是最新的,但 git push 拒绝非快进
我刚刚拉了一个新分支,做了一些本地更改,承诺并尝试推动。我收到此错误:! [拒绝]组->组(非快进)
所以我尝试拉,但被告知已经是最新的。
这是我拉然后推的内容。
~/dev$ git pull origin groups
Already up-to-date.
~/dev$ git push origin groups
To /mnt/ebs/git/repo.git
! [rejected] groups -> groups (non-fast forward)
error: failed to push some refs to '/mnt/ebs/git/repo.git'
谁能解释一下这是如何发生的以及我该如何解决它?
I've just pulled a new branch, made some local changes, committed and tried to push. I was given this error: ! [rejected] groups -> groups (non-fast forward)
So I tried a to pull but was told Already up-to-date.
Here's what I get pulling then pushing.
~/dev$ git pull origin groups
Already up-to-date.
~/dev$ git push origin groups
To /mnt/ebs/git/repo.git
! [rejected] groups -> groups (non-fast forward)
error: failed to push some refs to '/mnt/ebs/git/repo.git'
Can anyone explain how this can be happening and how I can fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我带着不同的问题来到这里。
我的 git 被设置为推送所有分支。我在 FOO 分支上,但它也在尝试推送 master,但它不是最新的。诀窍是注意到它正在尝试推送 master:
我将以下内容添加到我的 .gitconfig 中,默认情况下仅推送当前分支:
I came here with a different problem.
My git was set up to push all branches. I was on a branch FOO, but it was also trying to push master, which was not up to date. The trick was noticing it was trying to push master:
I added the following to my .gitconfig to only push the current branch by default:
这不是所提问题的答案。我遇到了相同错误消息的不同问题。
我的本地分支没有远程分支来从正确配置的 [git pull] 中提取更改。这从 git remote show origin 的 o/p 中可以明显看出。因此,我必须使用 git pull origin而不是 git pull 来拉取更改。
This is not an answer to the question asked. I had a different problem with the same error message.
My local branch did not have the remote branch to pull the changes from configured properly [git pull]. This was evident from the o/p of
git remote show origin
. So, I had to usegit pull origin <branch_name>
instead ofgit pull
to pull the changes.当您拉取分支时,您是否使用了“--track”选项(为了让本地分支跟踪远程分支)。如果没有,则可以解释“合并”命令不起作用。
您可以手动进行合并:
要比较本地和远程存储库,我建议您使用此命令(将其添加到别名中,很有用):
它将打印项目历史记录树,显示分支标签。所以你会看到你的分支和原始分支的分歧点。
注意:如果您想保留线性历史记录,而不是“合并”,您可以在推送之前在远程上对本地分支进行“变基”:
When you pulled the branch, did you use the "--track" option (in order to keep you local branch tracking the remote branch). If you did not, it can explain that the "merge" command that does not work.
You can do the merge manually:
To compare local and remote repos, I suggest you this command (add it in an alias, it is usefull):
It will print the project history tree, showing the branch labels. So you will see where your branch and the origin branch diverge.
Note: if you want to preserve a linear history, instead of a "merge", you can do a "rebase" of your local branch on the remote before pushing: