How do I reword the very first git commit message?

大城市里の小女人 提交于 2019-11-28 16:27:06

Do git rebase -i --root

(point to root instead of pointing to a specific commit)

This way, the root commit is also included and you can just reword it like any other commit.

The --root option was introduced in Git v1.7.12 (2012). Before then the only option was to use filter-branch or amend, which is typically harder to do.

Note: see also this similar question and answer.

You can always use git filter-branch --msg-filter:

git filter-branch --msg-filter \
  'test $GIT_COMMIT = '$(git rev-list --reverse master |head -n1)' &&
echo "Nice message" || cat' master

pcreux's gist has a good way to reword the first commit:

# You can't use rebase -i here since it takes the parent commit as argument.
# You can do the following though:
git checkout FIRST_COMMIT_SHA && git commit --amend && git rebase HEAD master
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!