I've spent more hours fixing Git than I want to admit. Not writing code. Not building features. Just untangling Git because I couldn't be bothered to spend twenty minutes setting it up properly across the four or five places I actually work.

Don't be me. Spend the twenty minutes.

The Mess I Made For Myself

Here's the setup that bit me. I work from a personal laptop, sometimes a second machine, occasionally a cloud dev environment, and lately through AI agents that commit on my behalf. Each one had its own idea of who I was. Different emails. Different SSH keys. Different default branches. One machine was still configured with an email from a job I left three years ago.

The fallout was exactly what you'd expect. Commits attributed to the wrong identity. GitHub refusing to link contributions to my profile because the email didn't match. Phantom merge conflicts from CRLF vs LF (the eternal Windows tax). An agent pushing to main because nobody told it not to. A signed-commit policy on one repo silently rejecting half my pushes until I realized GPG wasn't installed on the new laptop.

Worst one: I burned an afternoon rewriting commit history on a feature branch before a PR review, because I didn't want a reviewer asking why "[email protected]" was suddenly back from the dead. That's an afternoon I don't get back.

What "Set Up Right" Actually Means

There's no one perfect config, and I'm not going to pretend there is. But here's what I wish someone had beaten into me before I had four machines and three agents all committing as different people:

Set your global identity on every machine, the same day you set up the machine. git config --global user.name and user.email. Use the email tied to your GitHub account. If you have a work identity and a personal identity, use includeIf so the right one fires based on the directory. This one habit would have saved me half my Git pain.

Generate SSH keys per machine. Don't copy one key around like a USB stick from 2008. Name them clearly. Add them all to GitHub. When a machine dies, you revoke one key instead of panicking about which device has what.

Pick line endings and commit them to .gitattributes in every repo. Not user config. Repo config. Because the next person (or the next agent) will have different defaults and you'll be debugging phantom diffs at 11pm on a Tuesday.

Set a default branch name globally. Pick pull.rebase or merge and stop relitigating it every six months. Turn on rerere so Git remembers how you resolved that conflict last time.

If you're letting AI agents commit, give them their own identity. Don't let Claude or Cursor commit as you. When you're grepping the log six months from now trying to figure out who broke the build, you want to know whether it was a human or a bot.

The Real Cost Is Hidden

Nobody schedules "two hours to figure out why my contributions graph is empty." Nobody plans for the afternoon spent rewriting authorship on twelve commits. It shows up uninvited, usually right when you're trying to ship.

And it compounds. I cleaned up my Git setup a few weeks ago and counted roughly fifteen places where my identity, keys, or defaults were out of sync. Fifteen.

Git isn't hard. Git is fine. Setup work just feels boring, so we skip it, and then we pay interest on that decision every week for years. Spend the twenty minutes. Write yourself a checklist. Stick it in your dotfiles. Stop letting an old email address from a job you left in 2022 show up on a pull request in 2025.