git rebase master然后按原点分支导致非快进错误 [英] git rebase master then push origin branch results in non-fast-forward error
问题描述
这是场景
$ b 我试图在我的featureA分支上工作,同时保持它与master分支的最新状态。$ b
git clone ssh:// xxx / repo
git checkout -b featureA
$ git添加file.txt
$ git commit -m'添加文件'
$ git push origin featureA
同时有几个新的提交被推送给原始主人
git checkout master
git pull原点大师
git结账功能A
git转化大师
git推送原点功能A
到ssh:// xxx / repo
! [rejected] featureA - > featureA(非快进)
错误:未能将某些文件推送到'ssh:// xxx / repo'
为了防止您丢失历史记录,非快进更新被拒绝
在再次按下之前合并远程更改(例如'git pull')。有关详细信息,请参阅git push --help的快速转发部分的
'注意事项。
如何在不迫使服务器接受它的情况下重新绑定?
在重新绑定之后,您无法推送。这些提交现在有不同的SHA1,因为它们的历史不同。如果更新后的ref在它的祖先中不包含旧的ref,这是一个潜在的有害操作,git不会允许它。
如果你不希望强制执行。
如果您单独工作并且不需要其他人提交此分支,强制并不是很糟糕。
I am trying on working on my featureA branch while keeping it up-to-date with the master branch.
Here is the scenario
git clone ssh://xxx/repo
git checkout -b featureA
$ git add file.txt
$ git commit -m 'adding file'
$ git push origin featureA
meanwhile a couple new commits where pushed to origin master
git checkout master
git pull origin master
git checkout featureA
git rebase master
git push origin feature A
To ssh://xxx/repo
! [rejected] featureA -> featureA (non-fast-forward)
error: failed to push some refs to 'ssh://xxx/repo'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
How can I rebase without forcing the server to accept it?
You can't push after rebasing. The commits now have different SHA1s as their history is different. If the updated ref does not contain the old ref in it's ancestry, it's a potentially harmful operation and git won't allow it.
Your only alternate is to merge if you don't want to force.
Forcing is not so bad if you are working alone and don't need to have others committing to this branch.
这篇关于git rebase master然后按原点分支导致非快进错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!