Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magit - rename last commit

Tags:

git

magit

How do I rename the last commit in Magit (ie. edit the commit message) ?

I can see it in magit-log-buffer-file, but I don't know how to interact with it.

like image 914
nha Avatar asked Oct 02 '15 08:10

nha


2 Answers

Press c (Commit), then a (Amend), edit the message, C-c C-c, profit!

like image 174
choroba Avatar answered Sep 19 '22 05:09

choroba


There is a command called magit-commit-reword in latest Magit(Current version:v2.13.0)

Steps:

  1. Press c (Commit) at commit. (I usually move cursor to the first line after typing magit-status command)
  2. Press w (Reword)
  3. Rename
  4. Press C-c C-c to commit
  5. Done

Magit manual can be found here: https://magit.vc/manual/magit.html (Search reword in the page)

c w (magit-commit-reword)

Reword the last commit, ignoring staged changes. With a prefix argument keep the committer date, otherwise change it. The option magit-commit-reword-override-date can be used to inverse the meaning of the prefix argument.

like image 32
Frank_Xu Avatar answered Sep 21 '22 05:09

Frank_Xu