Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 731 Bytes

edit-old-commit.md

File metadata and controls

17 lines (13 loc) · 731 Bytes

Editing Old Commits Using CLI or with Lazygit

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, I use the following git commands.

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 select continue.