我如何修改以前的git commit [英] How can I amend a previous git commit

查看:76
本文介绍了我如何修改以前的git commit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经进行了2次git commit

I have made 2 git commit

 $ git log
commit 9613e1e84b42aeef645977272d310250339cf0e0

commit 01f8699be310f9a56a40835b48a922a879bba24f

每个文件都涉及不同的文件.而且我还没有推动.

Each of them touches DIFFERENT FILES. And I have NOT done a push.

但是我想修改提交01f8699be310f9a56a40835b48a922a879bba24f(不是最上面的).我该怎么办?

But I would like to amend the commit 01f8699be310f9a56a40835b48a922a879bba24f (not the top one). How can I do it?

我知道我可以使用'git commit --amend'来修改顶部提交.但第二个不是.

I know i can use 'git commit --amend' for the amending the top commit. But not the second one.

我该如何解决?

谢谢.

推荐答案

使用交互式资源库. git rebase -i HEAD〜2 将重新设置最后两个.您会在编辑器中看到一个列表,并且可以选择仅编辑一个或多个.

Use an interactive rebase. git rebase -i HEAD~2 will rebase the last two. You get presented with a list in your editor and can choose to edit just one or more.

这篇关于我如何修改以前的git commit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆