Identity, defaults, and the ignore file
Three pieces of setup outlive every project: who you are in commits, what defaults you accept, and what you refuse to track. Skip these and you will rediscover them as bugs later — wrong author on years of commits, surprise master branches, secret tokens leaked into history.
Git embeds your name and email in every commit. Set them globally once. The email does not need to be your real one — many people use the GitHub noreply address to avoid scraping. While you are there, set init.defaultBranch to main, set a sensible default editor, and let Git pick the modern pull.rebase behavior so blind git pull stops creating mystery merges. Configuration has three layers — system, global, local — and local always wins. git config --list --show-origin tells you which file each value came from, which is gold for debugging surprises.
.gitignore is the answer to "I do not want this in history." It is just a file in the repo with one pattern per line: build outputs, dependency folders, OS cruft, editor swap files, and — critically — secrets like .env, private keys, and credential dumps. The trap: .gitignore only affects untracked files. If you committed .env once, it stays tracked even after you add it to ignore. You must git rm --cached .env first. And if it ever held a real secret, treat it as compromised and rotate the secret — Git history is forever, even after deletion.
One more habit: set up SSH keys for at least one host (GitHub by default). HTTPS works, but SSH plus an agent eliminates daily password prompts and is the standard developer experience. ssh-keygen -t ed25519 -C "you@example.com", copy the .pub half to GitHub, and you will not type credentials for clones again.