如何修改旧的 Git 提交? [英] How to amend older Git commit?

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

问题描述

我已经提交了 3 次 git 提交,但没有被推送.如何修改旧的 (ddc6859af44) 和 (47175e84c) 不是最新的?

I have made 3 git commits, but have not been pushed. How can I amend the older one (ddc6859af44) and (47175e84c) which is not the most recent one?

$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

推荐答案

git rebase -i HEAD^^^

现在用edite(替换pick)标记您要修改的那些.现在保存并退出.

Now mark the ones you want to amend with edit or e (replace pick). Now save and exit.

现在进行更改,然后

git add .
git rebase --continue

如果要添加额外的删除,请从 commit 命令中删除选项.如果您想调整消息,只需省略 --no-edit 选项.

If you want to add an extra delete remove the options from the commit command. If you want to adjust the message, omit just the --no-edit option.

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

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