Is there a way to edit a commit?

Since a git commit is permanently store, is there a way to edit the commit once you ran it? For instance if I wanted to correct a commit to make it sound better in then Manhattan Zoo Projecthow do I go back and edit the commit for the Long-Tailed Chinchilla to make the statement clear after I already made two commits.

You’d remake the commit from the previous one, discarding the “mistake” commit. ie. you would reset to a previous commit without changing your local files, then commit again.

You can do it with git commit --amend, or you can just go ahead and keep committing and squash it down into a single or a few commits later.

3 Likes