ProgramGuru

Install Git and configure your identity

Install Git and configure your identity

Before creating real commits, configure the identity Git will write into new commits and make sure you know which settings apply globally versus only inside one repository.

What you’ll learn

  • Check the installed Git version.
  • Configure commit identity.
  • Distinguish global and repository-local settings.

Configuration precedence

  1. System

    Machine-wide defaults.

    broadest scope
  2. Global

    Defaults for your user account.

    ~/.gitconfig
  3. Local

    Repository-specific overrides.

    .git/config
.git/config

Git configuration has scopes

Git configuration can come from system, global and repository-local files. A local repository setting can override a global setting for that project.

Your Git user.name and user.email become commit metadata. They are not the same thing as signing in to GitHub. Authentication is a separate topic.

Set identity and inspect where settings come from

Run this in a disposable practice repository unless the lesson explicitly says otherwise.

git --version
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git config --global init.defaultBranch main
git config --list --show-origin

Use your own name and an email address appropriate for your commits. --show-origin is especially useful when a setting appears to be ignored because another configuration file overrides it.

Practice: Install and configure Git

Your task: Run git config user.name and git config user.email. Then create a test repository and set only that repository's user.email to a different value. Confirm the local value wins inside that repository.

Common pitfall to avoid

Do not paste passwords, access tokens or SSH private keys into git config. Identity settings describe commits; credentials should be handled by approved credential helpers, SSH agents or platform authentication flows.

Check your understanding

What does --global mean in git config?
Choose one answer. You can try again.

Answer and explanation

The setting applies to repositories for the current user unless overridden.

Correct. Repository-local settings can still override global values.

Install and configure Git: what to remember

Install Git and configure your identity is complete when you can explain the state being changed before you run the command, not merely repeat the syntax.

Read further: official supporting documentation.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: Create your first Git repository →