Edit Old Commit with Lazygit
Published on
I used to drop right to the shell whenever I needed to edit an old commit, be it a silly typo or a missing import I caught before pushing to a remote repository. Doing so with the git cli is not hard.
git log # look up the commit hash to be edited
git rebase --interactive 'abcdef^' # caret means its parent
# mark the commit as "edit" and apply changes
git commit --all --amend --no-edit
git rebase --continue
Using lazygit, the process is almost identical.
- Navigate to the commit to be edited and press
e
(edit commit). - Stage changes and press
A
(Amend commit with staged changes). - Press
m
(view merge/rebase options) and selectcontinue
.