How to update topic branch with upstream changes on master?

后端 未结 3 1267
广开言路
广开言路 2021-02-03 12:36

I start some work on a topic branch

    •-•-• < topic
   /
•-•       < master

I push the topic branch

$ git push origin t         


        
3条回答
  •  自闭症患者
    2021-02-03 12:41

    There are some problems with your question.

    1. You will not get merge conflicts when you push. This can only happen when you merge, rebase, cherry-pick or stash pop/apply.
    2. You cannot avoid conflicts if someone else is changing the same content as you are at the same time (even though it may be just you working on another copy of the repo).
    3. "All of my commits on topic are seen as uncommitted" doesn't make sense. You probably mean that "all of the changes that my topic branch commits introduce" are not committed yet due to a conflict when I try to rebase.

    Your steps are correct, except that you are ignoring that your rebase has stopped on a conflict and you are simply ignoring it. You must resolve your conflicts and then:

    git add confilctedfile1.txt conflictedfile2.txt
    git rebase --continue
    

    You may need to do this for all of your commits in your topic branch. Only when the rebase is complete should you push.

    Another note: For this reason, rebase is not the preferred workflow for day-to-day work. Merge is much easier and more accurate in what is happening with the code base. There are many reasons to favour merge over rebase.

提交回复
热议问题