Git:如何创建不同的未合并状态? [英] Git: how to create different unmerged states?
本文介绍了Git:如何创建不同的未合并状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我们添加了 git status
>未添加状态时由他们或都被删除
?
我试图重现后者在当前和合并分支中删除文件的情况下执行合并,但我无法创建此状态。 解决方案
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'重命名为Y'
git merge tmp
现在你有三种状态。
$ git status
#On分支大师
#未合并路径:
#(使用git add / rm ...来标记分辨率)
#
#由他们添加: X
#由我们添加:Y
#都删除:foo
#
没有更改添加到提交(使用git add和/或git commit -a)
When do different git status
unmerged states occur, like added by us
, added by them
or both deleted
?
I've tried to reproduce the latter by performing a merge where a file has been deleted in the current and merged-from branch, but I was not able to create this status.
解决方案
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")
这篇关于Git:如何创建不同的未合并状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文