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

Related Articles

Developer ToolsProductivity

VS Code Shortcuts That Will Make You Stop Reaching for Your Mouse

Most developers use maybe 10% of VS Code shortcuts. Here are the ones that actually matter -- the ones that eliminate mouse usage, speed up navigation, and make refactoring feel effortless.

9 min readRead More→
Developer ToolsProductivity

Chrome DevTools Shortcuts Every Developer Needs But Nobody Teaches

Chrome DevTools is the most powerful debugging tool most developers barely scratch the surface of. These shortcuts and hidden features will transform how you debug, inspect, and profile web apps.

10 min readRead More→
Developer ToolsProductivity

Terminal Shortcuts Every Developer Should Master (Bash, Zsh, and Beyond)

You spend hours in the terminal every day. These shortcuts for navigating, editing commands, managing history, and controlling processes will make the command line feel like an extension of your brain.

8 min readRead More→
Developer ToolsProductivity

macOS Shortcuts Developers Actually Use Every Day (Not the Obvious Ones)

Beyond Cmd+C and Cmd+V -- the macOS system shortcuts, window management tricks, and Spotlight hacks that developers use constantly but rarely talk about.

7 min readRead More→

Latest from the Blog

GamesMultiplayer

The Best Free Games to Play With Friends and Family Online

No console, no downloads, no setup - just open a browser and play. The best free 2-player and vs-computer games to enjoy with friends and family.

May 18, 2026Read More→
GamesBrain Games

Daily Puzzle Games: How a 5-Minute Habit Sharpens Your Brain

Daily puzzle games like Word Guess and Word Groups turn brain training into a habit. Here is why a 5-minute daily puzzle works - and which free ones to play.

May 17, 2026Read More→
GamesClassic Games

12 Timeless Classic Games You Can Play Free Online

Solitaire, Minesweeper, Snake, Pong and more - the classic games that defined gaming, all playable free in your browser with no download or sign-up.

May 16, 2026Read More→