Back to Blog
Developer ToolsProductivityGitShortcuts

Git Shortcuts and Aliases That Will Save You Hours Every Week

Published on April 4, 20268 min read

Git Shortcuts and Aliases That Will Save You Hours Every Week

If you are typing \git checkout\ in full every time, you are wasting hundreds of keystrokes a day. If you are typing \git log --oneline --graph --decorate --all\ from memory, you are showing off, but you are also wasting time.

Git aliases exist specifically for this. They transform your most-used Git commands from multi-word sentences into two or three character shortcuts. This is not about being lazy -- it is about removing friction from the thing you do most often.


Setting Up Git Aliases

Git aliases live in your \~/.gitconfig\ file. You can add them with the command line:

git config --global alias.co checkout

Or edit \~/.gitconfig\ directly and add them under an \[alias]\ section:

[alias]

co = checkout

br = branch

ci = commit

st = status

Both methods work identically. Editing the file directly is faster when adding multiple aliases.


The Essential Aliases Every Developer Needs

Navigation

These are the commands you type most often. Shortening them saves the most cumulative time.

  • co = checkout -- \git co main\ instead of \git checkout main\
  • br = branch -- \git br\ to list branches, \git br feature/new\ to create one
  • sw = switch -- \git sw main\ if you prefer the newer switch command
  • cb = checkout -b -- \git cb feature/new\ creates and switches to a new branch in one step

Committing

  • ci = commit -- \git ci -m "fix bug"\
  • ca = commit --amend -- fix the last commit message or add forgotten files
  • cm = commit -m -- \git cm "fix bug"\ saves typing the -m flag every time
  • ac = !git add -A && git commit -m -- stage everything and commit in one command: \git ac "fix bug"\

Viewing History

These are where aliases truly shine, because the useful log commands are absurdly long.

  • lg = log --oneline --graph --decorate --all -- a beautiful, compact view of your entire branch history
  • ll = log --oneline -20 -- last 20 commits, one line each
  • last = log -1 HEAD -- show only the most recent commit
  • hist = log --pretty=format:'%h %ad | %s%d [%an]' --date=short -- clean history with dates and authors

Status and Diff

  • st = status -sb -- short status with branch info (much cleaner than the default verbose output)
  • df = diff -- \git df\ is just nicer to type
  • ds = diff --staged -- see what is staged for commit (most developers forget this command exists)
  • dc = diff --cached -- same as ds, some people prefer this name

Advanced Aliases That Change Your Workflow

Undo Last Commit (Keep Changes)

> undo = reset HEAD~1 --mixed

\git undo\ resets the last commit but keeps all the changes in your working directory. This is the "oops, I committed too early" command that every developer needs.

Interactive Rebase on Last N Commits

> reb = "!f() { git rebase -i HEAD~$1; }; f"

\git reb 5\ opens an interactive rebase for the last 5 commits. Squash, reorder, or edit commits without remembering the full syntax.

Clean Up Merged Branches

> cleanup = "!git branch --merged | grep -v '\*\|main\|master\|develop' | xargs -n 1 git branch -d"

\git cleanup\ deletes all local branches that have already been merged. Run this weekly to keep your branch list manageable.

Stash with a Name

> save = stash push -m

\git save "work in progress on auth"\ creates a named stash instead of the default "WIP on branch" message. When you have multiple stashes, names are essential.

Show Stash List (Readable)

> stashes = stash list --format='%gd: %gs'

Shows a clean list of all stashes with their messages.

Quick Amend (No Message Change)

> oops = commit --amend --no-edit

Forgot to stage a file? \git add forgotten-file && git oops\ amends the last commit without changing the message.

Find Which Commit Introduced a String

> find = "!f() { git log --all -S"$1" --oneline; }; f"

\git find "TODO: fix this"\ shows every commit that added or removed that string. Incredibly useful for tracking down when something was introduced.


Shell Aliases: Beyond Git Config

Git aliases are great, but shell aliases are even faster for common workflows.

Add these to your \~/.zshrc\ or \~/.bashrc\:

alias g="git"

alias gst="git status -sb"

alias gco="git checkout"

alias gcm="git checkout main"

alias gp="git push"

alias gl="git pull"

alias glog="git log --oneline --graph --decorate -20"

alias gd="git diff"

alias ga="git add"

alias gc="git commit"

alias gcmsg="git commit -m"

alias gca="git commit --amend"

Now \gst\ shows status, \gco feature/x\ switches branches, and \gcmsg "fix"\ commits with a message. You are saving 3-5 keystrokes per command, dozens of times per day.


Workflow Shortcuts (Not Just Aliases)

Pull with Rebase by Default

> git config --global pull.rebase true

This makes \git pull\ use rebase instead of merge by default. No more unnecessary merge commits cluttering your history.

Auto-Stash on Rebase

> git config --global rebase.autoStash true

Automatically stashes your uncommitted changes before a rebase and re-applies them after. No more "cannot rebase: you have unstaged changes" errors.

Default Branch Name

> git config --global init.defaultBranch main

New repos start with "main" instead of "master."

Push Current Branch by Default

> git config --global push.default current

\git push\ automatically pushes the current branch to a remote branch with the same name. No more \git push -u origin feature/my-branch\.

Better Diff Output

> git config --global diff.algorithm histogram

The histogram algorithm produces cleaner, more readable diffs than the default Myers algorithm, especially for moved code blocks.


The "Oh No" Commands Every Developer Should Know

These are not aliases, but they are shortcuts in the sense that they get you out of trouble fast.

  • git reflog -- shows everything you have done, even things that \git log\ does not show. If you accidentally deleted a branch or reset too far, the commit is almost certainly still in the reflog.
  • git cherry-pick <hash> -- grab a single commit from another branch and apply it to your current branch.
  • git bisect -- binary search through commits to find which one introduced a bug. This is an underused superpower.
  • git stash pop -- apply the most recent stash and remove it from the stash list. Faster than \git stash apply\ followed by \git stash drop\.

Making It Stick

The same advice applies as with any shortcut system: pick three aliases that map to your most common commands and force yourself to use them for a week. Once they are muscle memory, add three more.

If you type \git status\ more than 10 times a day -- and you probably do -- switching to \gst\ saves you real, measurable time over a year.

The goal is not to memorize a huge list. The goal is to make the commands you already use feel effortless.

The best Git workflow is the one you do not have to think about. Aliases do not make you faster at Git -- they make Git disappear so you can focus on the code.

Check out more developer productivity tips on our blog and explore our free developer tools.

Explore Our Free Tools & Games

Check out our curated collection of completely free browser games, tools, and extensions.

Browse Free Stuff

More Articles

Developer ToolsJSON

Stop Squinting at Messy JSON - Format It Instantly (Free Tool Inside)

Messy JSON is a productivity killer. Learn why formatting matters, common JSON pitfalls developers hit daily, and try our free browser-based JSON Formatter that works instantly with zero sign-ups.

7 min readRead More→
Browser GamesFree Games

Best Free Browser Games You Can Play Right Now in 2025

Discover the top free browser games of 2025 that require no downloads, no installs, and no sign-ups. From puzzle games to multiplayer adventures, these games run right in your browser.

8 min readRead More→
Developer ToolsFree Tools

Free Developer Tools Every Programmer Needs in Their Toolkit

A comprehensive guide to the best free developer tools available online. From JSON formatters to regex testers, these browser-based tools will supercharge your productivity.

10 min readRead More→
Chrome ExtensionsProductivity

10 Free Chrome Extensions That Will Boost Your Productivity

These free Chrome extensions will transform how you browse, work, and manage your time online. From tab management to dark mode, these extensions are must-haves.

7 min readRead More→