Merging but overwriting changes in Git

前端 未结 2 654
走了就别回头了
走了就别回头了 2020-12-23 02:02

When I merge a branch in Git to master I often get merge conflicts. Is there a way to merge a branch and just overwrite the stuff in the current branch?

相关标签:
2条回答
  • 2020-12-23 02:35

    To overwrite your stuff in your branch and take their work, you should make

    git merge -X theirs {remote/branch} --> example:origin/master
    
    0 讨论(0)
  • 2020-12-23 02:41

    Add -X ours argument to your git merge command.

    Say you are working in your local branch. Then you want to merge in what went in the master:

    git merge -X ours master
    

    On the other hand if you are in master and want to merge your local branch into master then @elhadi rightly says you should use theirs:

    git merge -X theirs somebranch
    
    0 讨论(0)
提交回复
热议问题