git pull说最新的,但git推拒绝非快速前进 [英] git pull says up-to-date but git push rejects non-fast forward
问题描述
我刚刚拉了一个新的分支,进行了一些本地更改,承诺并试图推动。我被给出这个错误:! [被拒绝]组 - >>群组(非快进)
所以我尝试了一次拉,但被告知已经最新。
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?
推荐答案
当你拉动分支时,你是否使用了--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.
您可以手动进行合并:
git fetch
git merge origin/groups
为了比较本地和远程回购,我建议你这个命令(将它加入别名,它是有用的):
To compare local and remote repos, I suggest you this command (add it in an alias, it is usefull):
git log --graph --oneline --all --decorate
它会打印项目历史树,显示分支标签。所以你会看到你的分支和起源分支的分歧。
It will print the project history tree, showing the branch labels. So you will see where your branch and the origin branch diverge.
注意:如果你想保留线性历史,而不是合并,你可以做一个推送前您的本地分支的rebase:
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:
git rebase origin/groups
git push origin groups
这篇关于git pull说最新的,但git推拒绝非快速前进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!