我已经提交了3个git,但还没有被推送。
我如何修改旧的(ddc6859af44)和(47175e84c)而不是最近的?
$git log
commit f4074f289b8a49250b15a4f25ca4b46017454781
Date: Tue Jan 10 10:57:27 2012 -0800
commit ddc6859af448b8fd2e86dd0437c47b6014380a7f
Date: Mon Jan 9 16:29:30 2012 -0800
commit 47175e84c2cb7e47520f7dde824718eae3624550
Date: Mon Jan 9 13:13:22 2012 -0800
我准备了我的提交,我想用一个旧的修改,并惊讶地看到了rebase -我抱怨我有未提交的更改。但我不想再次指定旧提交的编辑选项进行更改。所以解决方案非常简单直接:
prepare your update to older commit, add it and commit
git rebase -i <commit you want to amend>^ - notice the ^ so you see the said commit in the text editor
you will get sometihng like this:
pick 8c83e24 use substitution instead of separate subsystems file to avoid jgroups.xml and jgroups-e2.xml going out of sync
pick 799ce28 generate ec2 configuration out of subsystems-ha.xml and subsystems-full-ha.xml to avoid discrepancies
pick e23d23a fix indentation of jgroups.xml
now to combine e23d23a with 8c83e24 you can change line order and use squash like this:
pick 8c83e24 use substitution instead of separate subsystems file to avoid jgroups.xml and jgroups-e2.xml going out of sync
squash e23d23a fix indentation of jgroups.xml
pick 799ce28 generate ec2 configuration out of subsystems-ha.xml and subsystems-full-ha.xml to avoid discrepancies
write and exit the file, you will be present with an editor to merge the commit messages. Do so and save/exit the text document
You are done, your commits are amended
荣誉归于:http://git-scm.com/book/en/Git-Tools-Rewriting-History
这里还演示了其他有用的git魔法。
我准备了我的提交,我想用一个旧的修改,并惊讶地看到了rebase -我抱怨我有未提交的更改。但我不想再次指定旧提交的编辑选项进行更改。所以解决方案非常简单直接:
prepare your update to older commit, add it and commit
git rebase -i <commit you want to amend>^ - notice the ^ so you see the said commit in the text editor
you will get sometihng like this:
pick 8c83e24 use substitution instead of separate subsystems file to avoid jgroups.xml and jgroups-e2.xml going out of sync
pick 799ce28 generate ec2 configuration out of subsystems-ha.xml and subsystems-full-ha.xml to avoid discrepancies
pick e23d23a fix indentation of jgroups.xml
now to combine e23d23a with 8c83e24 you can change line order and use squash like this:
pick 8c83e24 use substitution instead of separate subsystems file to avoid jgroups.xml and jgroups-e2.xml going out of sync
squash e23d23a fix indentation of jgroups.xml
pick 799ce28 generate ec2 configuration out of subsystems-ha.xml and subsystems-full-ha.xml to avoid discrepancies
write and exit the file, you will be present with an editor to merge the commit messages. Do so and save/exit the text document
You are done, your commits are amended
荣誉归于:http://git-scm.com/book/en/Git-Tools-Rewriting-History
这里还演示了其他有用的git魔法。