DEV Community

The AI producer
The AI producer

Posted on

12 Git Aliases That Replaced My Entire Git Workflow (Copy-Paste Ready)

If you type git push origin main more than five times a day, you're losing hours every week to keystrokes you don't need.

I spent years copy-pasting the same verbose Git commands. Then I discovered aliases — tiny shortcuts that compress ten-word commands into two letters. After running these for six months, I can't go back.

Here are the 12 aliases I actually use every day, with explanations and copy-paste configs.

1. git co — checkout

[alias]
  co = checkout
Enter fullscreen mode Exit fullscreen mode

The most basic one. git co main instead of git checkout main. Saves 7 characters every time. Over a year, that's thousands fewer keystrokes.

2. git br — branch

  br = branch
Enter fullscreen mode Exit fullscreen mode

git br to list branches, git br -d feature-x to delete one. Short, obvious, universal.

3. git ci — commit

  ci = commit
Enter fullscreen mode Exit fullscreen mode

But here's where it gets interesting. Combine it with flags:

  cm = commit -m
  ca = commit --amend --no-edit
  can = commit --amend --no-edit
Enter fullscreen mode Exit fullscreen mode

git cm "fix typo" replaces git commit -m "fix typo". git ca lets you add files to the last commit without rewriting the message.

4. git st — the status you actually want

  st = status -sb
Enter fullscreen mode Exit fullscreen mode

The -sb flag gives you short status with branch info. Instead of 15 lines of text, you get:

## main...origin/main
 M src/index.js
?? notes.txt
Enter fullscreen mode Exit fullscreen mode

One glance tells you everything: which branch, whether you're ahead/behind, what's modified, what's untracked.

5. git unstage — undo git add

  unstage = reset HEAD --
Enter fullscreen mode Exit fullscreen mode

Everyone Googles "how to unstage files git" at least once a month. Now it's just git unstage.

6. git last — show the last commit

  last = log -1 HEAD --stat
Enter fullscreen mode Exit fullscreen mode

Shows the most recent commit with the files it touched. Faster than scrolling through git log.

7. git lg — the log you'll actually read

  lg = log --graph --oneline --decorate --all --abbrev-commit
Enter fullscreen mode Exit fullscreen mode

This is the single most useful alias on this list. Instead of a wall of text, you get a clean visual graph:

* a1b2c3d (HEAD -> main) Fix header overflow on mobile
* e4f5g6h Add dark mode toggle
* i7j8k9l (origin/main) Initial commit
Enter fullscreen mode Exit fullscreen mode

Branch relationships, merge points, commit hashes — all in one readable view.

8. git undo — undo the last commit (keep changes)

  undo = reset --soft HEAD~1
Enter fullscreen mode Exit fullscreen mode

Committed too early? git undo rolls back the commit but keeps all your staged changes. Your work is safe — only the commit metadata goes away.

9. git wipe — nuclear option (DANGER)

  wipe = !git add -A && git commit -m 'WIPE SAVEPOINT' && git reset --hard HEAD
Enter fullscreen mode Exit fullscreen mode

When you've made a mess and want a clean slate — but with a safety net. This creates a commit with everything, then hard-resets. If you regret it later:

git reflog
git reset --hard <hash>
Enter fullscreen mode Exit fullscreen mode

The savepoint is always recoverable.

10. git pushup — push and set upstream in one go

  pushup = !git push -u origin $(git branch --show-current)
Enter fullscreen mode Exit fullscreen mode

Every developer types git push -u origin feature-branch when creating a new branch. This does it automatically for whatever branch you're on. Just git pushup.

11. git cleanup — delete merged branches

  cleanup = !git branch --merged | grep -v '\*\|main\|master\|develop' | xargs -n 1 git branch -d
Enter fullscreen mode Exit fullscreen mode

After a sprint, you accumulate 10+ dead branches. This deletes every branch that's already been merged — while protecting main/master/develop.

12. git recent — branches sorted by last commit

  recent = for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'
Enter fullscreen mode Exit fullscreen mode

Shows your branches sorted by most recent activity. When you come back from lunch and can't remember which branch you were on:

2026-07-02 feature-payment-flow
2026-07-02 main
2026-06-28 experiment-css-grid
2026-06-15 hotfix-login-redirect
Enter fullscreen mode Exit fullscreen mode

How to set them all up

Add everything to your ~/.gitconfig:

[alias]
  co = checkout
  br = branch
  cm = commit -m
  ca = commit --amend --no-edit
  st = status -sb
  unstage = reset HEAD --
  last = log -1 HEAD --stat
  lg = log --graph --oneline --decorate --all --abbrev-commit
  undo = reset --soft HEAD~1
  pushup = !git push -u origin $(git branch --show-current)
  cleanup = !git branch --merged | grep -v '\*\|main\|master\|develop' | xargs -n 1 git branch -d
  recent = for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'
Enter fullscreen mode Exit fullscreen mode

Or run this one-liner to add them all at once:

git config --global alias.co "checkout" && git config --global alias.br "branch" && git config --global alias.cm "commit -m" && git config --global alias.st "status -sb" && git config --global alias.lg "log --graph --oneline --decorate --all --abbrev-commit" && git config --global alias.unstage "reset HEAD --" && git config --global alias.undo "reset --soft HEAD~1"
Enter fullscreen mode Exit fullscreen mode

The payoff

After a week with these aliases, my Git workflow dropped from ~40 keystrokes per operation to under 10. On a busy day with 30+ commits, that's real time saved.

The best part? They're just shortcuts — nothing changes about how Git works. If you ever forget one, the full command still works.


If you found this useful, I put together a complete **Git Workflow Checklist* with 47 commands and patterns organized by daily workflow — branching, committing, reviewing, merging, and cleanup. It's the reference sheet I wish I had when I started.*

👉 The Git Workflow Checklist — 47 Commands & Patterns

What Git aliases do you use that I missed? Drop them below.

Top comments (0)