何时会发生不同的git status
未合并状态,例如added by us
,added by them
或both deleted
?
我尝试通过执行合并来重现后者,其中文件已在当前和合并分支中删除,但我无法创建此状态。
答案 0 :(得分:17)
您可以通过在每个分支中以不同方式重命名文件来获取所有这三个文件。
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
现在你有三个州。
$ 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")