← Back to All Cheatsheets
Version Control

⚙️ Git & Advanced Rebase Master Reference

Battle-tested git commands for interactive rebasing, branch cleanup, log visualization, and undoing commits.

1. Visualizing Commit History

# One-line Graph View of All Branches
git log --oneline --graph --all --decorate

# View Changes Made in Last 3 Commits
git log -p -n 3

2. Undo Operations & Resetting

# Undo Last Commit while Keeping Staged Changes
git reset --soft HEAD~1

# Discard All Local Uncommitted Changes
git reset --hard HEAD

# Recover Lost Commits via Reflog
git reflog
Support My Work