1

在 Git 中修改之前提交的内容

 2 years ago
source link: https://blog.yxwang.me/2009/11/git-modify-specified-commit/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

在 Git 中修改之前提交的内容

Tue, Nov 10, 2009 • Tooling

其实这个问题我以前在 Stackoverflow 上回答过别人(链接),不过现在自己反而忘了,还是贴在这下次查起来方便点

先用 git rebase bbc643cd^ --interactive 退回到要修改的commit的前一个点,这里 bbc643cd 就是要修改的 commit,执行后 git 会调用默认的编辑器显示该次 commit 到最新 commit 的所有记录,在这里我们把要修改的那一项的行首的 pick 改成 edit。

接下来运行 git commit --amend,使用默认编辑器修改这次 commit。

最后执行 git rebase --continue 就能提交修改后的 commit 并且返回到原来的 commit 了。

本作品采用知识共享署名-非商业性使用 3.0 版本许可协议进行许可,欢迎转载,演绎,但是必须保留本文的署名 zellux(包含链接),且不得用于商业目的。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK