Git 100 ยท lesson 1

Basic Configuration

Tell Git who you are once, and set the defaults every later lesson relies on.

Who are you?

Every commit records an author. Set your name and email before your first commit:


        git config --global user.name "Your Name"
        git config --global user.email "you@example.com"
      

Use the email of your GitHub account so your commits are linked to you.

Three levels of settings

--systemevery user on this computer/etc/gitconfig
--globalyou, in every repository~/.gitconfig
--localthis repository only.git/config
$ git config user.email

The most specific level wins: local beats global, global beats system.

Useful defaults


        # name new repositories' first branch "main"
        git config --global init.defaultBranch main
        # the editor Git opens for commit messages
        git config --global core.editor "code --wait"
        # what git pull does when histories diverge
        git config --global pull.rebase false
      

The last one is explained in Divergence and Conflicts.

Check what is set


        # one setting
        git config user.name
        # everything, and which file each value came from
        git config --list --show-origin
      

Next: the basic workflow.