如何以非交互方式重新排序Git中的提交

如何以非交互方式重新排序Git中的提交

本文介绍了如何以非交互方式重新排序Git中的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么非交互式的git命令实现了从之前到之后的变化?



之前:

  A --- B --- C --- D 





  A --- C'--- B'--- D'


解决方案

在您的情况下,您可以重新设定交互: git rebase -i HEAD〜4 然后您可以重新排序您的选择



例如,让我们在分支中添加三个文件:

  git add A 
git commit -mA

git add B
git commit -mB

git add C
git commit -mC

您的短日志将为:

  $ git短记录
(3):
如果你想用C语言重新排列B:

  $ git rebase -i HEAD〜2 
pick 1f9133d B
pick 33f41be C

您只需重新排列它们:

  pick 33f41be C 
pick 1f9133d B

完成写作后,请看短记:

  $ git shortlog 
(3):
A
C
B

您可以通过重新排序对所有提交执行相同的操作。这就像你看到的是你得到的,这是非常酷的:)


What non-interactive git command(s) achieve the change from Before to After?

Before:

A---B---C---D

After:

A---C'---B'---D'
解决方案

In your case, you can rebase interactive: git rebase -i HEAD~4 Then you can just reorder your picks

For example lets add three more files to our branch:

git add A
git commit -m "A"

git add B
git commit -m "B"

git add C
git commit -m "C"

Your shortlog will be:

$ git shortlog
 (3):
      A
      B
      C

If you want to reorder B with C:

$ git rebase -i HEAD~2
pick 1f9133d B
pick 33f41be C

You just re-order them to be:

pick 33f41be C
pick 1f9133d B

After you're done writing, see the shortlog:

$ git shortlog
 (3):
      A
      C
      B

You can do the same thing with all the commits by re-ordering. It is like what you see is what you get, which is pretty cool :)

这篇关于如何以非交互方式重新排序Git中的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 20:26