RBRunbook
Dev Tools

How to Set Up Git Properly for a New Developer

The default Git setup after installing is incomplete in ways that cause confusing errors weeks later. Here's the config every new machine actually needs.

DifficultyBeginner
Time10–15 min
PlatformAny
CategoryDev Tools

Installing Git and running git clone works immediately, which is exactly why the setup gaps don't show up until later — a commit under the wrong name, a permission error pushing to GitHub, or a wall of line-ending noise in a diff. Doing this setup once, in order, avoids all of them.

01Set your identity

Every commit is signed with a name and email; skip this and Git either refuses to commit or uses a generic placeholder that makes your commit history useless for blame/history purposes.

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Use the same email associated with your GitHub/GitLab account so commits link to your profile correctly.

02Set up SSH authentication instead of typing your password every push

GitHub and GitLab no longer accept plain passwords for pushes over HTTPS at all — you need either SSH keys or a personal access token. SSH is the more durable setup:

ssh-keygen -t ed25519 -C "you@example.com"

Add the resulting public key (~/.ssh/id_ed25519.pub) to GitHub under Settings → SSH and GPG keys. Test it:

ssh -T git@github.com

03Fix line endings before they cause fake diffs

Windows and Mac/Linux use different line-ending characters by default. Without this setting, files can show as "changed" in a diff when nothing meaningfully changed — just the line endings — which creates noisy, confusing pull requests.

04Set your default branch name

Recent Git versions default to master unless configured otherwise, while most hosted platforms now default new repos to main — a small mismatch that occasionally trips up first pushes.

git config --global init.defaultBranch main

05Set a default editor that isn't Vim, unless you actually know Vim

Git's default commit-message editor on many systems is Vim, and if you've never used it, a mistyped commit can leave you stuck in an editor you don't know how to exit (the answer, for the record, is Esc then type :wq). Set something familiar instead:

git config --global core.editor "code --wait"

(Substitute your editor of choice — this example uses VS Code.)

06Verify everything at once

git config --list

Check that identity, default branch, and line-ending settings all show the values you expect before your first real commit.

One more habit worth building early Add a .gitignore file to every new project before your first commit, not after. GitHub's gitignore template repository has one for nearly every language — removing an accidentally committed file later (like a credentials file) requires rewriting history, not just deleting it.
JM
Written by Jordan Malik Senior Editor, Systems & Networking — guide tested on a live Any setup before publishing
Last verified: July 2026