问题:
OK, I thought this was a simple git scenario, what am I missing? 好的,我以为这是一个简单的git场景,我缺少什么?
I have a master branch and a feature branch. 我有一个master分支和一个feature分支。 I do some work on master , some on feature , and then some more on master . 我在master上做一些工作,在feature上做一些,然后再在master上做更多的工作。 I end up with something like this (lexicographic order implies the order of commits): 我最终得到这样的东西(字典顺序暗示着提交的顺序):
A--B--C------F--G (master)
\
D--E (feature)
I have no problem to git push origin master to keep the remote master updated, nor with git push origin feature (when on feature ) to maintain a remote backup for my feature work. 我可以使用git push origin master来保持远程master更新,也没有问题,可以使用git push origin feature (在feature )来为我的feature工作维护远程备份。 Up until now, we're good. 到目前为止,我们还不错。
But now I want to rebase feature on top of the F--G commits on master, so I git checkout feature and git rebase master . 但现在我要重订feature在上面F--G上主提交,所以我git checkout feature和git rebase master 。 Still good. 还好。 Now we have: 现在我们有:
A--B--C------F--G (master)
\
D'--E' (feature)
Problem: the moment I want to backup the new rebased feature branched with git push origin feature , the push is rejected since the tree has changed due to the rebasing. 问题:当我要备份以git push origin feature feature分支的新的基于重载的feature ,由于树由于重新定基而发生了更改,因此该推送被拒绝了。 This can only be solved with git push --force origin feature . 这只能通过git push --force origin feature解决。
I hate using --force without being sure I need it. 我讨厌使用--force不确定自己是否需要它。 So, do I need it? 所以,我需要吗? Does the rebasing necessarily imply that the next push should be --force ful? 请问垫底一定意味着未来push应该是--force FUL?
This feature branch is not shared with any other devs, so I have no problem de facto with the force push, I'm not going to lose any data, the question is more conceptual. 此功能分支未与任何其他开发人员共享,因此对于强制推送我实际上没有问题,我也不会丢失任何数据,这个问题更具概念性。
解决方案:
参考一: https://stackoom.com/question/bVhB/功能分支重新设置后-Git推送被拒绝参考二: https://oldbug.net/q/bVhB/Git-push-rejected-after-feature-branch-rebase
来源:oschina
链接:https://my.oschina.net/u/4432649/blog/4322443