假设我们已提交A
和B
,B
取决于A
的修改。
我们希望还原A
,这会成功吗?另外,如果由'A'添加的行不再存在会发生什么?
答案 0 :(得分:7)
git
会报告回复导致冲突。 git status
将显示未合并的路径。
你可以像其他任何人一样resolve the conflict。
使用示例编辑:
$ mkdir foo
$ cd foo
$ git init
$ echo "this is a line in a file" > blah
$ echo "this is a second line in a file" >> blah
$ echo "this is a third line in a file" >> blah
$ git add blah
$ git commit -m "first commit"
# edit the second line in blah
$ git commit -am "second commit"
# remove the second line from blah
$ git commit -am "third commit"
$ git revert HEAD^ #revert the second commit
error: could not revert 4862546... another change
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
$ git status
# On branch master
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution)
#
# both modified: blah
#
no changes added to commit (use "git add" and/or "git commit -a")
如果第一次提交添加了文件而第二次修改了该文件,git status将显示:
$ git status
# On branch master
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add/rm <file>..." as appropriate to mark resolution)
#
# deleted by them: blah
#