can't push to branch after rebase

前端 未结 6 661
走了就别回头了
走了就别回头了 2021-01-29 17:28

We use git and have a master branch and developer branches. I need to add a new feature and then rebase the commits to master, then push master to CI server.

The problem

6条回答
  •  甜味超标
    2021-01-29 18:16

    The general answer that has already been given -- to use git push -f origin myNewFeature when pushing rebased changes -- is a good starting place. I'm writing this answer to address the edit about whether it will break your workflow.

    If we assume that you're going to be using git pull --rebase ... (or some variation on that) followed by a force-push to the remote branch, then the thing that breaks the workflow in your example is developer2 is merging myNewFeature into hisNewFeature. It makes sense to be able to rebase your own feature branch as long as nobody else is working on that branch, so you need rules to demarcate branch territory.

    You can get around this by a) establishing a rule that you only ever merge from master, or b) creating a collective develop branch, upon which you base your own myNewFeature branch, and establish a rule that you only ever merge from develop. master will then be reserved only for milestones or releases (or however else you want to set that up), and develop will be where you push each feature when it's ready to be integrated into other feature branches.

    I believe this could be considered a simplified version of the Gitflow workflow.

提交回复
热议问题