简体   繁体   English

如何修改以前的git提交

[英]How can I amend a previous git commit

I have made 2 git commit 我做了2个git提交

 $ git log
commit 9613e1e84b42aeef645977272d310250339cf0e0

commit 01f8699be310f9a56a40835b48a922a879bba24f

Each of them touches DIFFERENT FILES. 他们每个人都接触不同的文件。 And I have NOT done a push. 我没有做过推动。

But I would like to amend the commit 01f8699be310f9a56a40835b48a922a879bba24f (not the top one). 但是我想修改提交01f8699be310f9a56a40835b48a922a879bba24f(不是最重要的提交)。 How can I do it? 我该怎么做?

I know i can use 'git commit --amend' for the amending the top commit. 我知道我可以使用'git commit --amend'来修改top提交。 But not the second one. 但不是第二个。

How can I fix it? 我该如何解决?

Thank you. 谢谢。

Use an interactive rebase. 使用交互式rebase。 git rebase -i HEAD~2 will rebase the last two. git rebase -i HEAD~2将改变最后两个。 You get presented with a list in your editor and can choose to edit just one or more. 您将在编辑器中看到一个列表,并可以选择仅编辑一个或多个列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM