Git lets you revise local commit history before sharing it: reordering commits, changing messages or the files in a commit, squashing commits together, splitting them apart, or removing commits entirely. The cardinal rule is to avoid pushing until you are happy with your work; once pushed, consider it final unless you have good reason to change it. For the most recent commit, git commit --amend loads the previous message into an editor, or replaces the commit's content when you stage changes first, and --no-edit skips the editor. Amending changes the commit's SHA-1, behaving like a very small rebase, so do not amend a commit you have already pushed. For commits farther back, git rebase -i HEAD~3 opens an interactive session listing the last three commits, where commands such as reword, edit, squash, and fixup rewrite each step; squash melds a commit into the previous one and fixup does the same but discards its log message. Aiming for small, self-contained commits that rebase cleanly is Koskamo editorial guidance, not a Git requirement. Scope: Git. Reviewed October 4, 2026.
Rewriting history with amend and interactive rebase
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- git-scm.com
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.