Install and configure Git (first time)
When to use this: A new PC, or Git has never been set up on this machine.
Before you start
Steps
-
Check Git is installed
terminalgit --versionPrints the installed version. If PowerShell says the command is not recognised, close and reopen the terminal, or reinstall Git.
Expected output
git version 2.54.0.windows.1
-
Tell Git who you are
terminalgit config --global user.name "Your Name" git config --global user.email "you@example.com"Every commit records an author. Use the email that is on your GitHub account, or the private
noreplyaddress from GitHub, Settings, Emails, if you want to keep your real email hidden. -
Make new repos start on main
terminalgit config --global init.defaultBranch mainOlder Git versions created
master. GitHub and Vercel expectmain, so set it once here. -
Review your settings
terminalgit config --global --listShows everything stored in your global config file (
C:\Users\<you>\.gitconfig).Expected output
user.name=Your Name user.email=you@example.com init.defaultbranch=main
How to verify it worked
git config user.nameprints your name andgit config user.emailprints your email.
How to undo it
Change any value by running the same command again with a new value, or remove it:
git config --global --unset user.emailCommon errors and fixes
Author identity unknown / Please tell me who you are when committing You skipped the name and email step. Run the two git config --global user.* commands. 'git' is not recognized as a name of a cmdlet Git is not on PATH in this window. Open a new terminal. If it still fails, rerun the installer and keep the option 'Git from the command line and also from 3rd-party software'. Q&A
What is the difference between --global and no flag in git config?
--global writes to your user-level file and applies to every repo. Without a flag it writes to the current repo only (.git/config), which overrides the global value there.
Why set init.defaultBranch main?
So git init creates main instead of master, matching GitHub and Vercel defaults and avoiding a rename later.