git - 更改 Git 中的旧提交消息

标签 git commit

我必须将所有 git repo 提交消息中的文本替换为另一个文本。 似乎可以使用 git rebase -i ... 来打开文本编辑器,但我必须自动执行此操作。 是否可以使用某些 git 命令或 Java 库来实现?

最佳答案

git filter-branch 是用于自动批量历史重写的工具。

具体--msg-filter :

--msg-filter This is the filter for rewriting the commit messages. The argument is evaluated in the shell with the original commit message on standard input; its standard output is used as the new commit message.

就您而言,一个简单的 sed 作为命令可能就足够了。

关于git - 更改 Git 中的旧提交消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64495979/

相关文章:

mysql - 如果在关闭连接之前从未调用 transaction.Rollback/Commit 会发生什么?

git - 如何清理 Rebase 弄乱的 Git 提交

git - 丢弃之前的提交,强制推送到远程

SVN 在服务器端恢复

git - 我怎样才能找到空的 git 提交?

git status - 列出最后修改日期

git - 通过 pull 请求解决 merge 冲突

git - 切换 git 分支时我应该删除 .eslintcache 吗?

svn - 本地服务器的SVN,GIT或Mercurial

合法提交消息的 git 钩子(Hook)(#123 好消息)