I type these 50+ times a day
Add these to your ~/.gitconfig:
[alias]
s = status -sb
co = checkout
br = branch
ci = commit
lg = log --oneline --graph --decorate -20
undo = reset HEAD~1 --mixed
amend = commit --amend --no-edit
1. git s — Short Status
$ git s
## main...origin/main
M src/app.py
?? tests/new_test.py
Instead of the verbose default output. Shows branch tracking info in one line.
2. git lg — Visual Log
$ git lg
* a1b2c3d (HEAD -> main) Fix rate limiting bug
* d4e5f6g Add retry logic to scraper
|\
| * 7h8i9j0 (feature/auth) Add OAuth support
|/
* k1l2m3n Initial commit
See your entire branch history as a graph. Better than any GUI.
3. git undo — Undo Last Commit (Keep Changes)
$ git undo
Undoes the last commit but keeps all changes staged. Essential when you commit too early.
4. git amend — Quick Fix Last Commit
$ git add forgotten_file.py
$ git amend
Adds staged changes to the previous commit without changing the message. I use this 10+ times a day.
5. Custom: git wip — Save Work in Progress
[alias]
wip = !git add -A && git commit -m "WIP: $(date +%H:%M)"
$ git wip
[main abc1234] WIP: 14:32
Quick snapshot of your current state. Great before switching branches.
6. Custom: git fresh — Sync With Main
[alias]
fresh = !git checkout main && git pull && git checkout - && git rebase main
One command to update your feature branch with the latest main.
7. Custom: git cleanup — Delete Merged Branches
[alias]
cleanup = !git branch --merged main | grep -v main | xargs -r git branch -d
Cleans up all branches that have been merged. Run weekly.
Full .gitconfig block
[alias]
s = status -sb
co = checkout
br = branch
ci = commit
lg = log --oneline --graph --decorate -20
undo = reset HEAD~1 --mixed
amend = commit --amend --no-edit
wip = !git add -A && git commit -m "WIP: $(date +%H:%M)"
fresh = !git checkout main && git pull && git checkout - && git rebase main
cleanup = !git branch --merged main | grep -v main | xargs -r git branch -d
Copy-paste this into your ~/.gitconfig and you're done.
What git aliases do you use? I'm always looking for new ones.
Follow me for developer productivity tips. I write about Python, automation, and APIs.
More from me: 10 Dev Tools I Use Daily | 77 Scrapers on a Schedule | 150+ Free APIs
Top comments (0)