Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I reword the very first git commit message?

People also ask

How do I reword a commit message in git?

On the command line, navigate to the repository that contains the commit you want to amend. Type git commit --amend and press Enter. In your text editor, edit the commit message, and save the commit.


Do git rebase -i --root

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

This way, the first 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