显示当前的git交互式rebase操作

编程入门 行业动态 更新时间:2024-10-26 09:18:57
本文介绍了显示当前的git交互式rebase操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当在交互式转化过程中,例如 git rebase -i HEAD〜12 并添加/编辑一些提交,我经常会对我正在编辑的提交感到困惑,特别是当存在合并冲突时: p>

> git status rebase正在进行中;到55d9292 您目前正在'55d9292'重新招募分支'master'。 (修复冲突,然后运行git rebase --continue)(使用git rebase --skip跳过这个补丁)(使用git rebase --abort检查出原来的分支) 未合并路径:(使用git reset HEAD< file> ...来取消)(使用git add< file> ; ...来标记分辨率) 都被修改:文件 没有更改添加到提交中(使用git add和/或git commit -a)

如何清楚了解当前状态下涉及的所有修补程序?例如,什么是基础修补程序,我正在拾取哪个修补程序,哪些修补程序合并冲突来自哪里? 解决方案

p>如果你有冲突,你可以运行 git show 来查看上次应用的提交。

然后当打开冲突的文件,冲突将一方面显示最后应用提交时的文件状态,另一方面显示当前正在应用的提交文件的状态。

示例:

我创建了一个带有文件a的回购站。我的第一个提交是创建文件: $ b $ pre $ John @ debian-John:〜/ tmp / test(master#)✖( 1)> touch a John @ debian-John:〜/ tmp / test(master#)✔> git添加 John @ debian-John:〜/ tmp / test(master +)✔> git commit -m initial [master(root-commit)298299e] initial 1 file changed,0 insertions(+),0 deletions( - ) create mode 100644 a

然后,我修改了文件并将其作为commit1提交:

John @ debian-John:〜/ tmp / test(master)✔> echo aaa> a John @ debian-John:〜/ tmp / test(master *)✔> git添加 John @ debian-John:〜/ tmp / test(master +)✔> git commit -m commit1 [master 90b49f8] commit1 1个文件已更改,1个插入(+)

然后,再次执行提交commit2:

John @ debian-John:〜/ tmp / test(master)✔> echo bbb>> a John @ debian-John:〜/ tmp / test(master *)✔> git添加 John @ debian-John:〜/ tmp / test(master +)✔> git commit -m commit2 [master 14d798e] commit2 1个文件已更改,1个插入(+)

然后我重新删除了commit1:

John @ debian-John:〜/ tmp / test(master )✔> git rebase -i HEAD ^^ 自动合并 CONFLICT(内容):在错误中合并冲突:无法应用14d798e ... commit2 当你解决这个问题时,运行git rebase --continue。 如果您不想跳过此修补程序,请运行git rebase --skip。 要检出原始分支并停止重新绑定,请运行git rebase --abort。 'a'的记录preimage 无法应用14d798e ... commit2

Commit2因其上下文发生更改而无法应用(commit1缺失)。请注意错误:无法应用14d798e ... commit2 ,它具有commit2的散列。在冲突中,如果我运行 git show ,我会得到:

John @ debian-John:〜/ tmp / test(master * + | REBASE-i 1/1)✖(1)> git show commit 298299e3fb4e75c50aaa346c9f57c3b8885726f7(HEAD)作者:John Doe< john @ doe> 日期:星期五7月21日15:59:01 2017 +0100 初始 diff --git a / ab / a 新文件模式100644 index 0000000..e69de29 John @ debian-John:〜/ tmp / test(master * + | REBASE-i 1/1)✔> git状态正在进行互动式重置;到298299e 完成最后的命令(完成1个命令): pick 14d798e commit2 没有命令剩余。 您目前正在'298299e'上重新设置分支'master'。 (修复冲突,然后运行git rebase --continue)(使用git rebase --skip跳过这个补丁)(使用git rebase --abort检查出原来的分支) 未合并路径:(使用git reset HEAD< file> ...来取消)(使用git add< file> ; ...来标记分辨率) 都被修改:a 没有更改添加到提交中(使用git add和/或git commit -a)

而a的内容为:

John @ debian-John:〜/ tmp / test(master + | REBASE-i 1/1)✔> cat a << {<<<< HEAD ======= aaa bbb >>>>>>> 14d798e ... commit2

其中HEAD是最后一次应用(初始),第二部分是未能应用的提交。

我希望这会有帮助。

When in the middle of an interactive rebase, e.g. git rebase -i HEAD~12 and adding/editing some commits, I'm often confused as to which commit I'm editing, especially when there's a merge conflict:

> git status rebase in progress; onto 55d9292 You are currently rebasing branch 'master' on '55d9292'. (fix conflicts and then run "git rebase --continue") (use "git rebase --skip" to skip this patch) (use "git rebase --abort" to check out the original branch) Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add <file>..." to mark resolution) both modified: file no changes added to commit (use "git add" and/or "git commit -a")

How can I get a clear idea of all the patches involved in the current state? For example, what is the base patch, what patch I'm "picking", which patch the merge conflicts are coming from?

解决方案

If you have a conflict, you can run git show to see the last applied commit.

Then when opening your conflicting file, the conflict will show in one hand the state of the file at the last applied commit, and on the other hand the state of the file at the commit currently being applied.

Example:

I created a repo with a file "a". My first commit was to create the file:

John@debian-John: ~/tmp/test (master #) ✖ (1) > touch a John@debian-John: ~/tmp/test (master #) ✔ > git add a John@debian-John: ~/tmp/test (master +) ✔ > git commit -m initial [master (root-commit) 298299e] initial 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 a

Then, I modified the file and commited it as "commit1":

John@debian-John: ~/tmp/test (master) ✔ > echo aaa >a John@debian-John: ~/tmp/test (master *) ✔ > git add a John@debian-John: ~/tmp/test (master +) ✔ > git commit -m commit1 [master 90b49f8] commit1 1 file changed, 1 insertion(+)

Then, done it again for a commit "commit2":

John@debian-John: ~/tmp/test (master) ✔ > echo bbb >>a John@debian-John: ~/tmp/test (master *) ✔ > git add a John@debian-John: ~/tmp/test (master +) ✔ > git commit -m commit2 [master 14d798e] commit2 1 file changed, 1 insertion(+)

Then I rebased to remove commit1:

John@debian-John: ~/tmp/test (master) ✔ > git rebase -i HEAD^^ Auto-merging a CONFLICT (content): Merge conflict in a error: could not apply 14d798e... commit2 When you have resolved this problem, run "git rebase --continue". If you prefer to skip this patch, run "git rebase --skip" instead. To check out the original branch and stop rebasing, run "git rebase --abort". Recorded preimage for 'a' Could not apply 14d798e... commit2

Commit2 could not be applied because its context changed (commit1 missing). Please note the error: could not apply 14d798e... commit2 which has the hash of commit2. While in the conflict, if I run git show, I get:

John@debian-John: ~/tmp/test (master *+|REBASE-i 1/1) ✖ (1) > git show commit 298299e3fb4e75c50aaa346c9f57c3b8885726f7 (HEAD) Author: John Doe <john@doe> Date: Fri Jul 21 15:59:01 2017 +0100 initial diff --git a/a b/a new file mode 100644 index 0000000..e69de29 John@debian-John: ~/tmp/test (master *+|REBASE-i 1/1) ✔ > git status interactive rebase in progress; onto 298299e Last command done (1 command done): pick 14d798e commit2 No commands remaining. You are currently rebasing branch 'master' on '298299e'. (fix conflicts and then run "git rebase --continue") (use "git rebase --skip" to skip this patch) (use "git rebase --abort" to check out the original branch) Unmerged paths: (use "git reset HEAD <file>..." to unstage) (use "git add <file>..." to mark resolution) both modified: a no changes added to commit (use "git add" and/or "git commit -a")

And the content of a is:

John@debian-John: ~/tmp/test (master +|REBASE-i 1/1) ✔ > cat a <<<<<<< HEAD ======= aaa bbb >>>>>>> 14d798e... commit2

Where HEAD is the last commit applied (initial) and the second part is the commit which failed to be applied.

I hope it will help.

更多推荐

显示当前的git交互式rebase操作

本文发布于:2023-06-06 05:55:12,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:操作   git   rebase

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!