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

问题描述

我想重新排序git中的最后两个提交:



现在我有:

  $ git lg --oneline -4 
1e0ecba(HEAD,my-branch)修复T255
82d45dc django_extensions
af3953b根据CR
dae63ff全屏支持

我想要:

 $ 39 
$ b 82d45dc(HEAD,my-branch)django_extensions
1e0ecba根据CR $ b修正T255
af3953b的改进$ b dae63ff全屏支持


解决方案

git rebase --interactive - 这里是详细答案:



但是,如果您想对最后两次提交进行重新排序,您可以使用此git别名:



添加到〜/ .gitconfig

  [别名] 
reorder =!GIT_SEQUENCE_EDITOR = \sed -i -n'h; 1n; 2p; g; p'\git rebase -i HEAD〜2
pre>

然后:

  $ git reorder 
重新激活(2/2)
成功重新更新并更新了裁判/头像/我的分支。


I want to reorder last two commits in git:

right now I have:

$ git lg --oneline -4
1e0ecba (HEAD, my-branch) Fix for T255
82d45dc django_extensions
af3953b improvements according to CR
dae63ff Fullscreen support

I want to have:

$ git lg --oneline -4
82d45dc (HEAD, my-branch) django_extensions
1e0ecba Fix for T255
af3953b improvements according to CR
dae63ff Fullscreen support
解决方案

In general you have to use git rebase --interactive - here is detail answer how to reorder any number of commits:

But if you want to reorder last two commits you can use this git alias:

Add to ~/.gitconfig:

[alias]
    reorder = "!GIT_SEQUENCE_EDITOR=\"sed -i -n 'h;1n;2p;g;p'\" git rebase -i HEAD~2"

and then:

$ git reorder
Rebasing(2/2)
Successfully rebased and updated refs/heads/my-branch.

这篇关于如何重新排序git中的最后两个提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:53