Stop Fighting Git: Advanced Configuration to Make Git Work For You
Jordan Duabe shared amazing tips on customizing your git and workflow
At the recent GitHub Meetup, polyglot developer Jordan Duabe shared a brilliant masterclass on customizing your workflow, centered on the philosophy: git config --make-git-work-for-you.
Git is a powerful tool, but most developers only scratch the surface of its configuration options. By diving into your global .gitconfig, you can transform your daily interactions, saving keystrokes, automating repetitive tasks, and even improving the readability of your codebase reviews.
Fundamentals
I appreciate the fundamentals of Git are skipped over in the items below. So you may want to start here.
Here are the most impactful Git configuration changes shared from the session, covering everything from quality-of-life improvements to advanced security and contextual setups.
1. Quality of Life: Aliases, Autocorrect, and Shorter Commands
Why type git status when you can just type git st? Git aliases are a fundamental time-saver, and Jordan demonstrated how to build a robust set:
You can add these to your global config:
Pro Tip: Combine aliases with Git’s built-in correction feature:
# Enables prompt for suggested corrections on mistyped commands (e.g., git cx -> git checkout)
git config --global help.autocorrect prompt
2. Better Diffs and Log Cleanup
Your daily life in Git often involves looking at differences, and a better diff can dramatically improve code review speed and clarity.
A Smarter Diff Algorithm
Git’s default diff algorithm (myers) is decades old. The newer histogram algorithm is generally faster and more efficient at identifying moved or changed blocks of code, resulting in smarter diffs.
# Use the smarter diff algorithm
git config --global diff.algorithm histogram
# Enable clever renaming detection and better color coding for moved lines
git config --global diff.renames true
git config --global diff.color
Note: Patience is a precursor to histogram (see breakdown here)
3. Workflow Automation: The Rebase Revolution
If your team relies on rebasing to maintain a clean, linear history, these four settings will drastically simplify your life:
Auto-Rebase on Pull (
pull.rebase true): Automatically usegit rebaseinstead ofgit mergewhen runninggit pull.git config --global pull.rebase true
Auto-Squash for Fixup Commits (
rebase.autoSquash true): This is a game-changer for cleaning up history. When combined withgit commit --fixup=<SHA>,git rebase -iwill automatically mark your fixup commits to be squashed into their target commit.Auto-Stash During Rebase (
rebase.autoStash true): If you have uncommitted changes, Git will automatically stash them, perform the pull/rebase, and then re-apply your stash.The DRY Principle: Re-Re-Re-solve Conflicts (
rerere.enabled true): Git can actually remember how you resolved a conflict the last time you saw it. Enabling “Reuse Recorded Resolution” means Git will auto-apply your previous resolution if the same conflict crops up again during a series of rebases.
4. Advanced: Contextual Configs and Security
Conditional Includes for Context Switching
Do you use one email for work and another for your Open Source contributions? Using Conditional Includes (includeif) lets Git load different config files based on the directory path.
In your main ~/.gitconfig:
[includeif “gitdir:~/oss/”]
path = ~/.gitconfig-oss
[includeif “gitdir:~/work/”]
path = ~/.gitconfig-workThen, in ~/.gitconfig-oss, you can define your open-source identity:
[user]
email = my-oss.emailCommit Signing for Non-Repudiation
To guarantee the authenticity of your commits and ensure non-repudiation, you should sign them with a GPG key.
# Set your signing key
git config --global user.signingKey XXXX
# Globally enable signing for all commits and tags
git config --global commit.gpgSign true
git config --global tag.gpgSign trueYou can verify the signature with git log --show-signature.
Further Reading & Resources
Jordan Duabe shared a few excellent resources for those looking to continue their Git journey:
Pro Git Book: The definitive guide to Git.
Julia Evan’s Blog: Excellent for building intuition on how Git works.
“So You Think You Know Git?” A fantastic YouTube talk on tips and tricks.
A huge thanks to Jordan Duabe for the invaluable session! You can find more of his work at https://jduabe.dev/.
Thank you Microsoft and GitHub for continuing the support of the community. And a special thanks to Daniel Hardej for running the event.




