SO YOU THINK YOU KNOW GIT? 2026 ADVANCED GUIDE

Updated for 2026: This guide has been refreshed with modern Git features like git maintenance, git switch/restore best practices, and advanced .gitconfig patterns for high-velocity teams.

I spent years using Git before I realized I was barely scratching the surface. Like most devs, I learned add, commit, push, and pull, and figured I was “set.” It wasn’t until I started working on a repository with 1,000+ contributors that I realized my “basic” workflow was actually slowing me down—and causing unnecessary merge conflicts for my team.

Who Is This Guide For?

  • Senior Developers who want to polish their workflow and avoid the “oops, I merged the wrong thing” panic.
  • Tech Leads looking to standardize Git configurations across their organization.
  • Curious Engineers who suspect there’s a better way to handle rebasing than just git rebase --abort.

By the end of this guide, you will:

  • Optimize your .gitconfig for speed and readability.
  • Master the split between switch and restore to replace the clunky checkout.
  • Implement a “fearless rebasing” strategy that keeps your commit history clean without the risk of losing code.

Refining Your Git Configuration

The .gitconfig file is your personal command center. I used to think of it as just a place for my name and email, but it’s actually where you can fix some of Git’s most annoying defaults.

Essential Global Configs for 2026

I highly recommend setting these globally to save yourself from future headaches:

# Automatically setup tracking for new branches
git config --global push.autoSetupRemote true

# Use rebase by default when pulling to avoid "merge bubbles"
git config --global pull.rebase true

# Better diff colors and moves detection
git config --global diff.algorithm histogram
git config --global diff.colorMoved zebra

The Magic of Aliases

If you’re typing the same long commands every day, you’re wasting mental energy. Here are the aliases I use every single hour:

[alias]
    st = status -sb
    co = checkout
    br = branch
    lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

Modern Features: Switch and Restore

For a decade, git checkout was the Swiss Army Knife of Git. It did too much. In 2026, we should be using the specialized tools that Git introduced to fix this: switch and restore.

Why use git switch?

checkout could change branches or revert files. This led to mistakes. switch is only for branches.

  • Switch to a branch: git switch feature-x
  • Create and switch: git switch -c new-feature

Why use git restore?

When you want to throw away changes in your working directory, restore is your friend.

  • Discard changes in a file: git restore app.js
  • Unstage a file: git restore --staged app.js

It’s cleaner, safer, and much easier to teach to junior developers.


Fearless Rebasing

Rebasing has a reputation for being “dangerous,” but that’s only because people use it without a safety net. I prefer rebasing over merging for feature branches because it keeps the history linear and easy to audit.

My Golden Rule of Rebasing

Never rebase a branch that you have shared with others. If it’s your local feature branch, rebase away. If it’s main, use merge.

The “Strategic” Rebase Workflow

  1. Sync with main: git fetch origin && git rebase origin/main
  2. Fix conflicts locally: Take your time. Your branch is local, so you aren’t blocking anyone.
  3. Clean up your mess: Use git rebase -i HEAD~3 (interactive rebase) to squash “oops” and “fix” commits before you push.

Keeping Your Repo Healthy

As repositories grow, they get slow. Git now has a built-in feature to handle this automatically: git maintenance.

I recommend running this once on any large project:

git maintenance start

This sets up background tasks to pre-fetch objects and update the commit-graph, making commands like git status and git log feel snappy even in massive monorepos.


Next Steps

  1. Review your .gitconfig and add the aliases above.
  2. Try using git switch for your next branch change.
  3. Read more about advanced Git on Advanced Git Techniques for Modern Development /.

Related articles on sanj.dev:


Sources