2012-07-15 136 views
2

我知道你能做到git --amend改变的最新提交的提交信息。但是,如何更改第二个最新的提交消息?以下是我现在提交的内容:如何修改第二最新提交

commit eca1b2db14da8ace66aed172056c6e7aaf323093 
Author: Adam Sandler 
Date: Fri Jul 13 18:00:13 2012 -0700 

    Pre-final work on appending new items on top 

commit 7d21bbfea24cb72eafbe0213cad6339354078a81 
Author: Adam Sandler 
Date: Fri Jul 13 11:57:40 2012 -0700 

    Pre-final work on appending new item on top. 

    Loading more when user reaches the end of the scroll view 

我想更改其中包含两条消息的提交7d21bbfea24cb72eafbe0213ca

+0

的可能重复[我怎样才能修改以前的git的承诺(http://stackoverflow.com/questions/5587880/how-can-i-amend -a-previous-git-commit) – Daenyth 2012-07-15 01:47:01

回答

3

似乎总是有很多的方式来做事的混帐,我不是专家,但这里是我在那种情况下做的:

$ git rebase -i HEAD~2 

这带来了的东西,如一个编辑器:

pick eca1b2d Pre-final work on appending new items on top 
pick 7d21bbf Pre-final work on appending new item on top. 

以下有一些说明。如果您更改了pickreword上提交您想要更改的消息,然后保存并退出编辑器,则会打开另一个编辑器,您可以在其中重新编写提交消息。

我只做到这一点上我还没被推送的提交。如果您已经被推提交其消息你改变,你会想读此:How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?

+0

我实际上已经将它与另一个分支合并,并且这样做会向我提供来自其他提交的提交消息 – xonegirlz 2012-07-16 03:46:09

相关问题