Git Aliases That Save Me 30 Min Every Day

· Tutorials

Every git alias I use daily — from staging commits to force-pushing safely — with the full .gitconfig snippet ready to copy.

Last updated: July 25, 2026 · 4-minute read

My terminal history says I type git an average of 47 times per day. With the aliases below, each of those commands takes roughly 2.5 fewer seconds to type. That is about 30 minutes saved per working day — not life-changing on its own, but it compounds into a noticeably smoother workflow over months.

The Full .gitconfig

This goes in \~/.gitconfig. If you already have aliases defined, merge them in manually to avoid overwriting.

The Daily Drivers

These are the aliases I use literally every session:

co — Switching branches is the single most common git action. git co main instead of git checkout main saves six keystrokes, multiple times per hour.

st — The -sb flag gives you a short, branch-aware status. Clean output, one line per changed file, with the branch name up top.

cm — I commit frequently. git cm "fix sidebar overflow on mobile" is faster than the full command, especially because I am almost always passing a message inline rather than opening an editor.

push — Yes, I aliased push itself. The default git push behavior without branch tracking is unpredictable and has caused me to push to the wrong branch more than once. --force-with-lease is the safe version of --force — it refuses to push if someone else has added commits to the remote. A post on r/git with 2,100 upvotes called --force-with-lease "the only safe force push" and I agree.

pull — --rebase keeps your history linear. Without it, pull creates a merge commit every time someone else pushed to the branch you are working on. Linear history makes git log --graph actually readable.

The Safety Net

undo — git undo runs reset --soft HEAD~1, which undoes your last commit but keeps all the staged changes. I use this at least twice a day when I commit too early or catch a typo right after hitting enter. Someone on X posted "git undo should be a default command" and they are not wrong.

unstage — If you accidentally git add . when you meant to add one file, git unstage path/to/file removes it from the staging area without deleting your changes.

stash-all — The default git stash ignores untracked files, which means your new files are still sitting there when you switch branches. The --include-untracked flag catches everything.

Log and History

lg — This is the one I show people most often. The \--oneline --graph --decorate -20 combination gives you a visual branch graph of your last 20 commits with branch names and tags. It makes rebasing and cherry-picking visually obvious.

recent — Lists all local branches sorted by last commit date. Useful when you have 15 feature branches and cannot remember which ones are stale.

Setting It Up

Drop the config block into \~/.gitconfig. On macOS and Linux, that file lives at the root of your home directory. On Windows with Git Bash, it is usually at C:\Users\<you\.gitconfig. You can verify by running git config --list.

If you want to see how I wire this into a full deployment workflow, I cover that in a separate post. I use these aliases daily across my projects and experiments. More CLI and productivity posts are on the blog.

---

Not affiliated with Git. Tools used: iTerm2, Warp Terminal, Git 2.47.