我们使用git,并且有一个master分支和一个developer分支。我需要添加一个新功能,然后将提交重新分配到主服务器,然后将主服务器推送到CI服务器。
问题是,如果我在重定基期间遇到冲突,则在重定基完成后,我无法推送到我的远程开发人员分支(在Github上),直到我拉开我的远程分支为止。这将导致重复提交。没有冲突时,按预期方式工作。
问题:在重新设置基准并解决冲突后,如何在不创建重复提交的情况下同步本地和远程开发人员分支
建立:
// master branch is the main branch
git checkout master
git checkout -b myNewFeature
// I will work on this at work and at home
git push origin myNewFeature
// work work work on myNewFeature
// master branch has been updated and will conflict with myNewFeature
git pull --rebase origin master
// we have conflicts
// solve conflict
git rebase --continue
//repeat until rebase is complete
git push origin myNewFeature
//ERROR
error: failed to push some refs to 'git@github.com:ariklevy/dropLocker.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
// do what git says and pull
git pull origin myNewFeature
git push origin myNewFeature
// Now I have duplicate commits on the remote branch myNewFeature
编辑
听起来这会中断工作流程:
developer1在myNewFeature上工作developer2在hisNewFeature上工作都使用master作为主要分支
developer2将myNewFeature合并到他的NewFeature中
developer1调整基准,解决冲突,然后为myNewFeature强制推送到远程分支
几天后,developer2将myNewFeature再次合并到他的NewFeature中
这会导致其他开发人员讨厌developer1吗?
force
推送)
rewriting history
,这是rebase
we
?您是一个不只是您的团队吗?they
说(那些比我了解更多的人),如果您共享代码,则不应该使用rebase
。为什么你不只是在做git pull
和git merge
?