Install and configure Git (first time)

safe beginner #install#config#setup

When to use this: A new PC, or Git has never been set up on this machine.

Before you start

Steps

  1. Check Git is installed

    terminal
    git --version

    Prints 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
  2. Tell Git who you are

    terminal
    git 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 noreply address from GitHub, Settings, Emails, if you want to keep your real email hidden.

  3. Make new repos start on main

    terminal
    git config --global init.defaultBranch main

    Older Git versions created master. GitHub and Vercel expect main, so set it once here.

  4. Review your settings

    terminal
    git config --global --list

    Shows 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.name prints your name and git config user.email prints your email.

How to undo it

Change any value by running the same command again with a new value, or remove it:

terminal
git config --global --unset user.email

Common 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.

Practice these as flashcards →

Terms in this scenario

Related scenarios

My notes

Saved in this browser only.