linux - 使用 "git revert"取消添加一行的更改?

标签 linux git

下面的 pastebin 是一个包含一个文件的 repo,每行输入一、二、三、四、五。

每一行都被单独提交到 git 中:

http://pastebin.ca/raw/2136179

然后我尝试使用命令 git revert <commmit which creates two> 删除第二行

并得到:

error: could not revert b4e0a66... second
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'

这么简单的事情应该不会有冲突吧?还是我做错了/得到了错误的命令?

merge 细节似乎也没有意义:

one
<<<<<<< HEAD
two
three
four
five
=======
>>>>>>> parent of b4e0a66... second

那不是说除一个之外的所有东西吗?我原以为只有两个人会受到影响......

git 1.7.10

最佳答案

我试着重复你的步骤,发现了同样的问题。似乎您只能还原最近的提交。 在我的存储库中:

$ git log --oneline
9a25594 five
f8f1ec4 four
3c75345 three
e6cd245 two
8349ccc one
d2f16c4 for stkofl  <<==== ignore this one

$ git revert 9a25 --no-edit
Finished one revert.
[master 82bbc79] Revert "five"
 1 files changed, 0 insertions(+), 1 deletions(-)
$ git reset --hard
HEAD is now at 82bbc79 Revert "five"

恢复不是一组连续提交的任何提交集,包括 HEAD(最近的提交)似乎是不允许的。

当然,你可以这样做:

    $ git show e6cd |patch -R
    patching file file
    Hunk #1 succeeded at 1 with fuzz 1.

然后提交结果。

关于linux - 使用 "git revert"取消添加一行的更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10159775/

相关文章:

linux - 如何使用 Puppet 工具安装 Websphere Application Server

php - 管道关闭后向进程发送哪个信号

c - 为什么 linux 108 上的 unix-sockets 允许最大路径长度?

linux - 如何获取Linux中特定进程的CPU利用率

xcode - 无法 merge 分支 Xcode Sourcecontrol

git - bash - 引号中的变量

linux - "Argument list too long"显示所有列表元素

git - git 中有没有办法 check out 除 1 或 2 之外的所有文件?

xcode - Xcode 是否向后兼容?Git 是否适用于不同的 Mac 操作系统?

git clone 工作但在替换防火墙后面的 SSL 证书后推送不工作