In a git merge, how do you just replace your version with the version git says there is a conflict with?

后端 未结 2 804
-上瘾入骨i
-上瘾入骨i 2021-02-01 16:56

I have two files: A and B. If I have been working on A and a partner is working on B, I want to merge files A and B. B is already committed. Let\'s say my partner already made t

相关标签:
2条回答
  • 2021-02-01 17:45

    If their is a conflict during a merging operation (merge, cherry-pick, rebase, etc...) you can resolve conflict by picking one side of the changes by doing :

    git checkout --ours <path> (this will choose the local changes)

    or

    git checkout --theirs <path> (this will choose the remote changes)

    then finishing resolving the conflict as usual with:

    git add <path>
    

    then commit with:

    git commit
    
    0 讨论(0)
  • 2021-02-01 17:51

    Let's say both you and your partner modified the same file, and is committed to each respective repository.

    git pull                             # fetch/merge partners changes
    # merge fails, conflict
    git checkout origin FILE_TO_REPLACE  # replace changes with partners ver
    git commit                           # finish merge
    
    0 讨论(0)
提交回复
热议问题