Coding

Git Aliases You Didn't Know You Needed

Git Aliases You Didn't Know You Needed

Cover: Git Aliases You Didn't Know You Needed

Git's default commands aren't long, but you type them dozens of times a day — which is exactly why shaving them down adds up. Aliases turn your most-used commands into something you can type without thinking.

Where aliases live

Git aliases are just entries in your .gitconfig file, usually at ~/.gitconfig on Mac/Linux or C:\Users\you\.gitconfig on Windows. You can add them by hand, or use git config --global alias.NAME "command" from the terminal — both end up in the same place.

The aliases worth adding first

Add these under a [alias] section in your .gitconfig:

  • st = status — the single most-typed Git command, now three keystrokes shorter.
  • co = checkout — for jumping between branches all day.
  • br = branch — quick list of local branches.
  • cm = commit -m — pairs naturally with a quoted message right after.
  • last = log -1 HEAD — shows your most recent commit without scrolling through history.
Setting one from the terminal instead: git config --global alias.st status writes the exact same line into your .gitconfig — useful if you don't want to open the file directly.

A more useful one: a readable log

Git's default log output is verbose and hard to scan. This alias compresses it into one line per commit, with a bit of color and a graph of branches:

lg = log --oneline --graph --decorate --all

Run git lg and you'll get a compact visual history that's actually readable at a glance — genuinely one of the highest-value aliases you can set up.

Undoing the last commit without losing your changes

undo = reset --soft HEAD~1 rolls back your most recent commit but keeps all the changes staged, ready to re-commit differently. It's the alias to reach for when you commit too early or write a bad message.

Comments