I am wondering if I could change the description of the past git commits. Anyone knows? for example, for commit 1234556, the original description is "abc", I want to change it to "123"
Asked
Active
Viewed 58 times
1 Answers
4
This involves rewriting history. You shouldn't do that if you already pushed the commits to a place accessibly by others. However, if you know that nobody else has fetched your changes yet, it's safe to do.
- If it's the latest commit, run
git commit --amend
and edit the message. - If it's an older commit, run
git rebase -i 1234556^
(don't forget the^
), then replacepick
withreword
in the line of the commit you want to change and exit the editor. This will open another editor where you can edit the commit message right afterwards.
In both cases, you need to git push -f
(forced push) afterwards unless the commits hadn't been pushed yet.

ThiefMaster
- 310,957
- 84
- 592
- 636