Git: how to create different unmerged states?

前端 未结 1 1578
走了就别回头了
走了就别回头了 2020-12-16 00:05

When do different git status unmerged states occur, like added by us, added by them or both deleted?

I\'ve tried

相关标签:
1条回答
  • 2020-12-16 00:54

    You can get all three by renaming a file differently in each branch.

    git init
    touch foo
    git add foo
    git commit -m 'initial commit'
    git checkout -b tmp
    git mv foo X
    git commit -m 'rename to X'
    git checkout -
    git mv foo Y
    git commit -m 'rename to Y'
    git merge tmp
    

    Now you have all three states.

    $ git status
    # On branch master
    # Unmerged paths:
    #   (use "git add/rm ..." as appropriate to mark resolution)
    #
    #       added by them:      X
    #       added by us:        Y
    #       both deleted:       foo
    #
    no changes added to commit (use "git add" and/or "git commit -a")
    
    0 讨论(0)
提交回复
热议问题