DEV Community

楊東霖
楊東霖

Posted on • Originally published at devplaybook.cc

How to Speed Up Your Git Workflow: Practical Tips for 2026

Most developers spend more time in Git than they realize. Typing the same long commands, writing commit messages from scratch, checking out the right branch, cleaning up after merges—these moments add up. The average developer runs hundreds of Git commands a week.

This guide covers concrete changes that reduce friction in your Git workflow: aliases, hooks, smarter commit habits, and tools that take mechanical work off your plate.


Start With Aliases for the Commands You Run Most

Git aliases map short commands to longer ones. You set them once and benefit every day.

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.lg "log --oneline --graph --decorate --all"
Enter fullscreen mode Exit fullscreen mode

After this, git st replaces git status, git lg gives you a readable branch graph, and git co feature/my-branch saves seven characters on every checkout.

For even more power, add a "stash-and-switch" alias:

git config --global alias.sw "!f() { git stash && git checkout $1 && git stash pop; }; f"
Enter fullscreen mode Exit fullscreen mode

Now git sw main stashes your working changes, checks out main, and restores your stash. One command instead of three.


Write Commit Messages That Actually Help Future You

The commit message you write in 30 seconds might save you (or a teammate) 30 minutes later. The simplest rule: the subject line explains what changed, the body explains why.

A message like fix bug is technically a commit message. But fix null dereference in user profile when avatar URL is absent tells a reviewer—or your future self after a git bisect—exactly what happened.

The AI commit generator can help here. Paste your diff and it generates a conventional commit message with the right prefix (feat:, fix:, chore:), a clear subject, and optional body. Use it when you're moving fast and don't want to slow down to write a quality message from scratch.

Conventional commits format:

<type>(<scope>): <subject>

[optional body]

[optional footer]
Enter fullscreen mode Exit fullscreen mode

Types: feat, fix, docs, style, refactor, test, chore.


Use git add -p for Cleaner Commits

If you've made multiple changes in the same file—fixed a bug and cleaned up some formatting—git add -p lets you stage individual hunks rather than the whole file. This keeps your commits focused and makes the history easier to navigate.

git add -p
Enter fullscreen mode Exit fullscreen mode

Git walks you through each change and asks what to do: stage it (y), skip it (n), split it further (s), or edit the hunk manually (e).


Stop Re-Typing Long Branch Names

Tab completion is a baseline. If your shell doesn't complete branch names on git checkout, install git-completion for bash or zsh.

For fuzzy branch switching, combine with fzf:

git branch | fzf | xargs git checkout
Enter fullscreen mode Exit fullscreen mode

This gives you an interactive branch picker—type to filter, press Enter to check out. No more git branch -a | grep feature/auth followed by copy-pasting.


Use Git Hooks to Automate Quality Checks

Git hooks run scripts at specific points in the workflow—before a commit, before a push, after a merge. A pre-commit hook that runs your linter means bad code never makes it into the history.

Example pre-commit hook (.git/hooks/pre-commit):

#!/bin/sh
npm run lint
Enter fullscreen mode Exit fullscreen mode

Make it executable:

chmod +x .git/hooks/pre-commit
Enter fullscreen mode Exit fullscreen mode

For team-wide hooks, use Husky (JavaScript projects) or pre-commit (Python projects) to version-control the hook configuration.


Clean Up Merged Branches Automatically

After a branch gets merged, it shouldn't live in your local repo forever. This alias deletes local branches that are already merged into main:

git config --global alias.cleanup "!git branch --merged main | grep -v 'main\\|master\\|develop' | xargs git branch -d"
Enter fullscreen mode Exit fullscreen mode

Run git cleanup after a merge sprint to remove the noise.


Understand What You're About to Push

Before pushing, run:

git log origin/main..HEAD --oneline
Enter fullscreen mode Exit fullscreen mode

This shows you exactly which commits will go up. No surprises in the PR.

The git command builder is useful when you're constructing less common commands—cherry-picks, rebases, stash operations—and want to make sure you have the flags right before running something potentially destructive.


Use the Interactive Cheatsheet for Less Common Commands

You run git reset, git rebase, git cherry-pick, and git bisect occasionally—not daily. When you do, you often need to look up the syntax.

The interactive Git cheatsheet organizes these commands by use case. Instead of searching Stack Overflow, you filter by what you're trying to do: "undo last commit", "apply commit from another branch", "find which commit introduced a bug".


Generate a .gitignore That Actually Covers Your Stack

The gitignore generator produces comprehensive .gitignore files for any language, framework, or tool combination. Paste in your stack—Node, Python, JetBrains, macOS—and get a file that covers all the noise: node_modules, .DS_Store, .env, __pycache__, editor configs.

Start every project with a proper .gitignore. Cleaning up accidentally committed files later is slower and messier than preventing it.


Summary: Quick Wins First

If you implement one thing from this list today:

  1. Add aliases for the 3-4 commands you run most
  2. Set up a pre-commit hook for linting
  3. Use git add -p to write more focused commits
  4. Bookmark the AI commit generator and Git cheatsheet for when you need them

The goal is to make the mechanical parts of Git invisible so you can focus on the actual work. Each small friction point removed adds up to meaningful time saved over a week, a month, a year.


Level Up Your Dev Workflow

Found this useful? Explore DevPlaybook — cheat sheets, tool comparisons, and hands-on guides for modern developers.

🛒 Get the DevToolkit Starter Kit on Gumroad — 40+ browser-based dev tools, source code + deployment guide included.

Top comments (0)