Setup Git


Before we can use Git, we need to configure it.

Scott Chacon and Ben Straub have written a book titled Pro Git which discusses how to use Git.  The book is released under the Creative Commons Attribution Non Commericial Share Alike 3.0 license.  Below are instructions from chapter 1.6 Getting Started – First-Time Git Setup.   

Follow the instructions below to inform Git of your identity, set a default branch name, and check your settings.

Your Identity

We can use Git to track changes to the code we write by issuing git commit commands.  In order to record who made the changes we need to inform Git of our real name and email address.

Run the following commands but replace John Doe with your real name (keep the quotes).

$ git config --global user.name "John Doe"

Run the following command but replace johndoe@example.com with the email address to which you would like to receive notification emails.

$ git config --global user.email johndoe@example.com

Your default branch name

Git allows multiple people to work on different branches of the same project.  By default, when Git creates a project repository it creates a default branch named master. Enter the following command to change the default branch name from master to main.

$ git config --global init.defaultBranch main

Checking Your Settings

Enter the following command to review your current configuration settings.

$ git config --list