加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 使用“git revert”来支持添加一行的更改?

发布时间:2020-12-13 22:52:28 所属栏目:Linux 来源:网络整理
导读:以下pastebin是一个repo,其中一个文件在每行上键入一个,两个,三个,四个,五个. 每行都单独提交到git中: http://pastebin.ca/raw/2136179 然后我尝试使用命令git revert commmit删除第二行,这将创建两个 得到: error: could not revert b4e0a66... secondhin
以下pastebin是一个repo,其中一个文件在每行上键入一个,两个,三个,四个,五个.

每行都单独提交到git中:

http://pastebin.ca/raw/2136179

然后我尝试使用命令git revert< commmit删除第二行,这将创建两个>

得到:

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'

对于这么简单的事情应该没有冲突吗?或者我做错了/得到了错误的命令?

合并细节似乎也没有意义:

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.

然后提交结果.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读