我刚刚注意到,如果我们有本地和 origin/develop
看起来像
local: A---B
origin/develop: A---B
如果我然后执行git flow feature start Z
并工作一段时间,我最终可能会得到:
local: A---B
origin/develop: A---B---C---D
我现在执行git flow feature finish Z
并且收到有关以下内容的警告:
Branches 'develop' and 'origin/develop' have diverged.
And local branch 'develop' is ahead of 'origin/develop'
我现在有(没有推送):
local: A---B---Z
origin/develop: A---B---C---D---E
我尝试执行git pull
,然后将一堆更新 merge 到develop
中,所以我最终得到:
local: A---B---Z-----------Z'
\--C---D---E--/
origin/develop: A---B---C---D---E
如果我执行git push origin/develop
,我就会搞乱我们漂亮整洁的单个develop
流,所以经过一些谷歌搜索后,我最终做了:
git pull --rebase --prune
git push origin develop
这使我恢复到:
local: A---B---C---D---E---Z
origin/develop: A---B---C---D---E---Z
这样做时,我实际上发现以前的功能也因同样的问题而失败...我以为我们使用 git flow
来 stash 所有这些常见的问题和陷阱。
那么,我是否错误地使用了 git flow ?在功能完成
之前是否应该执行一些额外的命令以确保您不会失去同步?
最佳答案
正如我mentioned here ,您可以在本地设置:
git config --global pull.rebase true
git config --global rebase.autoStash true
这样,在 git flow finish
之后完成的任何 develop
pull 都会有效地 rebase Z
(尚未推送)自动。
关于如果起源/开发不同步,git flow 功能完成不会推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51529600/