gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 01:27:38 26 4
gpt4 key购买 nike

下面的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com