Setup: Install Git, Git Bash, and connect to GitHub

Install Git for Windows, make Git Bash your terminal, create a GitHub account, and tell Git who you are.

Novice · Operating System · Git · Updated

After this lesson you can

  • Make Git Bash the default profile in Windows Terminal
  • Configure Git on Windows with your name, email, default branch, and editor

Key takeaways

  • Git for Windows installs Git, Git Bash, and Git Credential Manager together.
  • Set Default profile to Git Bash on the Startup page of Windows Terminal's Settings, so every new window opens in Git Bash.
  • git config --global sets your name, your email, the default branch name (main), and the editor Git opens (code --wait).
  • Use the same email for Git as for GitHub, so GitHub can link your commits to your account.
  • git config --global --list shows what you set. Running a git config command again replaces the old value.

Windows only. Git saves the history of your code. GitHub stores that history online. In this exercise you install Git for Windows, which also gives you Git Bash and Git Credential Manager, then create your GitHub account and set Git up to use both.

Install Git for Windows

The Git installer asks many questions. You will change three answers, so run it with --interactive to see its windows. In Windows Terminal (PowerShell), run:

winget install -e --id Git.Git --interactive

Click Yes if Windows asks whether the app may make changes. Then go through the installer. Click Next on every page, except these three:

  1. Select Components: check Add a Git Bash Profile to Windows Terminal.
  2. Choosing the default editor used by Git: open the list and choose Use Visual Studio Code as Git's default editor.
  3. Adjusting the name of the initial branch in new repositories: choose Override the default branch name for new repositories and make sure the box says main.

Leave every other page as it is. Click Install, then Finish.

Make Git Bash your terminal

Close Windows Terminal completely and open it again.

  1. Click the arrow beside the + button. You should now see Git Bash in the list.
  2. Click Settings in that list (or press Ctrl+,).
  3. On the Startup page, set Default profile to Git Bash.
  4. Click Save, then close the Settings tab.

Close Windows Terminal and open it again. It now opens in Git Bash, with a prompt like this:

alex@LAPTOP MINGW64 ~
$

From now on, run every command in Git Bash. Check where you are:

pwd

You should see /c/Users/ followed by your username: your home folder.

Create your GitHub account

If you already have a GitHub account, sign in at github.com and skip to the next section.

Otherwise, go to github.com/signup and create a free account:

  • Use an email address you will keep after the bootcamp.
  • Choose a username you would be happy to show an employer. Your GitHub profile becomes part of your portfolio.

GitHub sends a code to your email to confirm it. Enter the code to finish.

Tell Git who you are

Every commit you make is signed with a name and an email. Use your real name, and the same email you used for GitHub, so GitHub can link your commits to your account. Replace the example values with your own:

git config --global user.name "Alex Rivera"
git config --global user.email "alex.rivera@example.com"

The installer already set your branch name and editor for this copy of Git. Set them in your own settings too, so they show up in the check below and stay set if Git is reinstalled:

git config --global init.defaultBranch main
git config --global core.editor "code --wait"

The first names the main branch of every new repository main, the same name GitHub uses. The second tells Git to open VS Code when it needs you to type a message, and to wait until you close that file.

Check your work

git --version
git config --global --list
git config --get credential.helper

You should see:

  • git version 2. followed by more numbers, and windows
  • your user.name, your user.email, init.defaultbranch=main, and core.editor=code --wait
  • manager, which means Git Credential Manager will sign you in to GitHub

You will push your first code to GitHub, and see Git Credential Manager in action, in the last Setup exercise.

Common problems

What you see What to do
No Git Bash in the profile list Run the install command again and check Add a Git Bash Profile to Windows Terminal on the Select Components page. Or open Git Bash from the Start menu for now.
git: command not found in PowerShell Close every Windows Terminal window and open a new one.
A typo in your name or email Run the same git config --global command again with the correct value. It replaces the old one.
credential.helper prints nothing Run git config --global credential.helper manager, then check again.

Check yourself

2 questions to try on the lesson page.

So what

Every commit you make from now on carries the name and email you set here, and every new window opens in Git Bash, ready for the commands in the lessons.

Key terms

  • git config
  • Default branch