【发布时间】:2013-09-17 16:22:37
【问题描述】:
我在使用 git revert 命令时遇到问题。我使用 Ubuntu 12.04 Linux 和 Git 版本 1.7.9.5。
- 我在本地 PC 上创建了一个全新的
b_test_repo,并通过远程origin b_test_repo对其进行跟踪。 - 我在本地创建了一个包含两行文本的单个文件 (commit
A),并且仅在本地master分支中成功提交。
为了尝试git revert,我又生成了 3 个提交,每个提交都添加了一行文本。所以我的master 提交历史看起来像:
A - B - C - D
在哪里
-
A- 第 1 行和第 2 行的新文件 -
B- 添加了一行 -
C- 添加了一行 -
D- 添加了一行
在所有这些提交之后,文件包含 5 行:
line1
line2
line3
line4
line5
然后,我想恢复提交B,这将呈现没有line3的文件,这是由提交B添加的:
git status
# On branch master
nothing to commit (working directory clean)
我输入:
git revert -n master~2
在不提交更改的情况下恢复提交B 的效果,但得到以下内容:
error: could not revert 1a13ad6... Adding one line
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 在确定文件中需要更改的内容时遇到问题。
我在这里缺少什么?请赐教!
【问题讨论】: