我们使用 git,并且有一个主分支和开发人员分支。我需要添加一个新特性,然后将提交重新设置为 master,然后将 master 推送到 CI 服务器。
问题是,如果在 rebase 期间出现冲突,那么在 rebase 完成之后,我就不能推送到我的远程开发人员分支(在 Github 上) ,直到我拉出我的远程分支。这会导致重复提交。当没有冲突时,按预期工作。
问题: 在 rebase 和冲突解决之后,如何在不重复提交的情况下同步本地和远程开发人员分支
设置:
// 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
因此,听起来这将打破工作流程:
开发人员1正在开发 myNewFeature 开发者2正在开发他的新功能 都是以师父为主干的
Developer2将 myNewFeature 合并到他的 NewFeature 中
Developer1重新建立基础,解决冲突,然后强制推送到 myNewFeature 的远程分支
几天后,developer2再次将 myNewFeature 合并到他的 NewFeature 中
这会导致其他开发人员讨厌 developer1吗?