bashbeginner
Git Amend and Fixup Commits
Amend the last commit or create fixup commits that auto-squash during rebase.
bashPress ⌘/Ctrl + Shift + C to copy
# Amend the last commit message
git commit --amend -m "feat: improved login flow"
# Amend: add forgotten files to last commit (keep message)
git add forgotten-file.ts
git commit --amend --no-edit
# Amend: change author of last commit
git commit --amend --author="Name <email@example.com>"
# --- Fixup commits (for auto-squash during rebase) ---
# Create a fixup commit that targets a specific commit
git add .
git commit --fixup=abc1234
# Creates: "fixup! original commit message"
# Auto-squash fixup commits during rebase
git rebase -i --autosquash main
# Fixup commits are automatically moved and marked as 'fixup'
# Enable autosquash by default
git config --global rebase.autoSquash true
# --- Squash commit (like fixup but lets you edit message) ---
git commit --squash=abc1234
# Amend a commit that's NOT the latest (using rebase)
git rebase -i HEAD~3
# Change 'pick' to 'edit' on the target commit
# Make your changes, then:
git add .
git commit --amend --no-edit
git rebase --continueUse Cases
- Fixing typos in the last commit message
- Adding forgotten changes to recent commits
- Organizing fixup commits before PR review
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashintermediate
Git Cherry-Pick Commits Example
Apply specific commits from one branch to another using cherry-pick with conflict resolution.
Best for: Backporting bug fixes to release branches
#git#cherry-pick
bashintermediate
Git Cherry-Pick — Apply Specific Commits
Cherry-pick single, multiple, or ranges of commits from other branches without full merge.
Best for: Backporting hotfixes to release branches
#git#cherry-pick
bashbeginner
Git Reset — Soft, Mixed, and Hard Explained
Understand the three git reset modes and when to use each for undoing commits safely.
Best for: Undoing accidental commits before pushing
#git#reset
bashintermediate
Git Hooks Pre Commit
Git workflow: git-hooks-pre-commit
Best for: version control
#git#version-control