All chapters in this track
- 011. The Mental Model
- 022. Essential Setup
- 033. Core Daily Workflow
- 044. Branching
- 055. Merging & Conflict Resolution
- 066. Rebasing
- 077. Remote Repositories
- 088. Stashing
- 099. Undoing Things
- 1010. Tagging & Versioning
- 1111. Cherry-Pick
- 1212. Git Bisect & Blame
- 1313. Git Hooks
- 1414. Submodules
- 1515. Team Workflows
- 1616. Power Commands & Aliases
- 1717. Reflog: The Safety Net
- 1818. Practice Tasks
- 19Quick Reference Cheatsheet
Chapter 16 of 19
16. Power Commands & Aliases
Useful one-liners
# Pretty log graph
git log --oneline --graph --all --decorate
# Find what you typed (all history)
git log --all --full-history -- "**/lost-file.txt"
# Search commit messages
git log --grep="payment" --oneline
# See all changes to a function
git log -L :function_name:file.py
# Compare two branches
git diff main..feature/login
# List files changed in last commit
git show --name-only HEAD
# Count commits per author
git shortlog -sn
# Remove file from staging but keep on disk
git rm --cached sensitive.env
# Temporarily switch to another branch without losing work
git switch -c temp-branch # or git stash
# Clean untracked files (preview first)
git clean -n # dry run
git clean -fd # delete untracked files and directories (PERMANENT)
# Set upstream and push in one command
git push -u origin $(git branch --show-current)
Aliases (add to ~/.gitconfig)
[alias]
s = status
st = status -sb
co = switch
cb = switch -c
lg = log --oneline --graph --all --decorate
undo = reset HEAD~1
unstage = restore --staged
aliases = config --get-regexp alias
pushup = push -u origin HEAD
wip = commit -am "WIP: checkpoint"
unwip = reset HEAD~1
Usage: git lg, git undo, git pushup