将消息更改为已提交的提交

时间:2016-03-08 22:49:09

标签: git gitlab

我一直致力于一个项目,其中所有提交消息都是用西班牙语制作的。现在我正与其他国家的人合作,所以我想将提交消息更改为英语。有可能吗?

1 个答案:

答案 0 :(得分:2)

是的,您将不得不做所谓的“互动式基础”。这将允许您(其中包括)重写提交消息。

使用git log --topo-order --reverse查找第一个提交ID(它将是第一个),然后使用git rebase -i重写所有提交消息。它看起来像这样。

$ git rebase -i <first commit ID>

pick ea21ffd Version 2.13.1
pick b98b956 Allow the extra_compiler_flags option to work.
pick d096ee5 Fix "perl5i -e" from segfaulting.
...

# Rebase 42c49b0..d096ee5 onto 42c49b0 (3 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.

在您的情况下,您将每pick更改为reword

有关执行交互式rebase的详细信息,请参阅Pro Git中的Changing Multiple Commit Messages

请注意,这样做不会重写历史记录, 您创建新历史记录 。所有提交ID都将更改。任何签出代码的人在尝试推拉时都会收到错误并且必须重新同步。有关详细信息,请参阅Pro Git手册中的The Perils Of Rebasing

相关问题