SovranCode
Learn Git & GitHub Install Git and Configure Identity
This device
Course contentsInstall Git and Configure Identity · 41 topics

1. Git Fundamentals

Git IntroductionGit Version ControlGit vs GitHubGit InstallationGit Working TreeGit RepositoryGit CommitGit .gitignoreGit Project: Learning Journal

2. Git History

Git LogGit DiffGit ResetGit RevertGit StashGit Project: Messy Repository

3. Branches & History

Git BranchGit MergeGit Merge ConflictsGit RebaseGit Cherry-PickGit TagsGit Project: Feature Branch

4. Remotes and GitHub

Git RemoteGitHub AuthenticationGitHub RepositoryGitHub ForkGitHub IssuesGitHub PagesGit Project: Two Clone Sync

5. GitHub Collaboration

GitHub Pull RequestsGitHub Code ReviewGit Branching WorkflowGitHub Branch ProtectionGitHub CollaborationGitHub ContributingGit Project: Reviewed Pull Request

6. Automation and Professional Git

GitHub ActionsGit InternalsGit RecoveryGitHub SecurityGit Project: Team Repository CIProject
Learn Git & GitHub35 complete · 1 planned

1. Git Fundamentals

Git IntroductionGit Version ControlGit vs GitHubGit InstallationGit Working TreeGit RepositoryGit CommitGit .gitignoreGit Project: Learning Journal

2. Git History

Git LogGit DiffGit ResetGit RevertGit StashGit Project: Messy Repository

3. Branches & History

Git BranchGit MergeGit Merge ConflictsGit RebaseGit Cherry-PickGit TagsGit Project: Feature Branch

4. Remotes and GitHub

Git RemoteGitHub AuthenticationGitHub RepositoryGitHub ForkGitHub IssuesGitHub PagesGit Project: Two Clone Sync

5. GitHub Collaboration

GitHub Pull RequestsGitHub Code ReviewGit Branching WorkflowGitHub Branch ProtectionGitHub CollaborationGitHub ContributingGit Project: Reviewed Pull Request

6. Automation and Professional Git

GitHub ActionsGit InternalsGit RecoveryGitHub SecurityGit Project: Team Repository CIProject
PREVIOUS LESSONGit vs GitHub
NEXT LESSON · PLANNEDGit Working Tree
Git foundations 55 min

Install Git and Configure Identity

A trustworthy Git setup is not “the installer finished.” You need to know which executable your terminal runs, which identity future commits will publish, which configuration scope supplied each value, and which defaults are deliberate rather than copied from an old tutorial.

What you will leave with

You will install or verify Git on Windows, macOS, or Linux; configure a public commit identity and default branch; inspect effective configuration with its source; and diagnose command-not-found, wrong-path, and wrong-identity problems.

A reliable setup has four proofs

ExecutableThe terminal runs a known Git installation from an expected path.
IdentityFuture commits carry the name and email you intend to publish.
DefaultsNew repositories begin with a deliberate initial branch name.
AuditYou can trace every effective setting back to its scope and file.

Before installing: check what already exists

Do not reinstall Git simply because a lesson begins with installation. First ask the current terminal. If git --version reports a Git 2.x release and the executable path is one you understand, you may already have everything this lesson needs.

git --version

# macOS or Linux
command -v git

# Windows PowerShell or Command Prompt
where.exe git

Version answers “can it run?”

A version response proves this shell can launch Git. Distribution package versions vary; an older supported release is not automatically broken.

Path answers “which Git?”

Several installations can coexist. The first matching executable in PATH wins, which may differ between a terminal and an editor.

Fresh shell answers “did PATH update?”

Close and reopen terminals after installation. Existing processes may retain the old environment.

One method answers “who updates it?”

Prefer one understood installer or package manager so future upgrades have a clear owner.

Do not download Git from an advertisement

Use the official git-scm.com downloads page, your operating system’s package manager, or a source approved by your organization.

Install Git on Windows

  1. 01
    Use Git for Windows

    Download the maintained installer from git-scm.com. It includes Git, Git Bash, OpenSSH, and Git Credential Manager.

  2. 02
    Choose the editor deliberately

    The installer may ask for Git’s text editor. Choose one you can actually exit and save from; this can be changed later.

  3. 03
    Keep a practical PATH option

    The recommended option that exposes Git to command-line and third-party tools works for most learners.

  4. 04
    Open a new terminal

    Verify from PowerShell, Command Prompt, Git Bash, or the editor terminal you intend to use.

Git Bash is optional. It provides a Unix-like shell on Windows, but Git also works in PowerShell and Command Prompt. A shell is the interface; Git is the program.

Install Git on macOS

Run git --version first. macOS may offer Apple Command Line Tools when Git is missing. Accepting that prompt provides a working Git installation. If you already use Homebrew and need its release cadence, brew install git is another reasonable path.

# Apple Command Line Tools
xcode-select --install

# Or, when Homebrew is already your package manager
brew install git

git --version
command -v git
Multiple versions are not automatically a problem

If Homebrew installs Git but command -v git still reports /usr/bin/git, the shell is choosing Apple’s copy first. Fix the package manager’s documented shell setup instead of appending random PATH lines.

Install Git on Linux

Use your distribution’s normal package manager. This integrates Git with trusted repositories, signatures, dependency handling, and system updates. Compiling Git from source is unnecessary for a normal learning workstation.

# Debian or Ubuntu
sudo apt update && sudo apt install git

# Fedora
sudo dnf install git

# Arch Linux
sudo pacman -S git

git --version
command -v git

Package freshness differs by distribution. The goal here is a supported Git 2.x release with predictable updates, not the highest version number on the internet.

Verify the terminal you will actually use

Repeat verification inside your editor’s integrated terminal if that is where you will work. A standalone terminal and an editor launched earlier can inherit different PATH values.

Healthy evidence

One understood executable

  • git --version prints a version.
  • The path matches your chosen installation.
  • A fresh terminal reports the same result.
  • Your editor terminal agrees.
Investigate

Conflicting or missing evidence

  • “command not found” or “not recognized.”
  • Terminal and editor report different paths.
  • An older executable wins unexpectedly.
  • Only an administrator account can run Git.
QUICK CHECK

Test what you learned

Which environment variable determines which matching Git executable the shell finds first?

Configure the identity future commits will publish

Every commit records author and committer metadata. The name and email become durable project history when the commit is shared. Use values you are willing to publish. They do not need to match your operating-system account name.

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

Replace the examples; do not type Your Name or you@example.com literally. Quotes preserve spaces in a name. The --global scope writes defaults for repositories used by the current operating-system account.

Identity is not authentication

user.name and user.email label commits. They do not sign in to GitHub, prove ownership of the email, or grant push access. HTTPS credentials, SSH keys, and hosted permissions are separate.

Choose an email with privacy and attribution in mind

If commits will be public, a personal email inside commit history may be copied indefinitely. GitHub can provide an account-specific no-reply commit address. Copy the exact address shown in GitHub email settings if you want account attribution without publishing your personal address.

Public personal work

Use a public address you control or the exact GitHub no-reply address associated with your account.

Employer repository

Use the identity required by organizational policy, often as a repository-local override.

Shared computer

Do not assume one global identity fits every user. Separate operating-system accounts are safer and clearer.

Existing commits

Changing configuration affects future commits. It does not silently rewrite identities already recorded in history.

Understand configuration scopes and precedence

Git combines settings from several levels. System applies machine-wide. Global applies to the current user. Local lives in one repository and overrides matching broader values there. Command-specific options can be more specific still.

system  /etc/gitconfig              core.autocrlf=input
global  ~/.gitconfig                user.name=Ada Lovelace
global  ~/.gitconfig                user.email=ada@example.com
global  ~/.gitconfig                init.defaultbranch=main
local   .git/config                 user.email=ada@company.example

In the example, commits in that repository use ada@company.example, while other repositories use ada@example.com. The local value wins because it is more specific—not because it was written more recently.

Local configuration requires a repository

You have not initialized one in this course yet. The next lessons will explain the working tree and repository before creating the first commit. For now, understand why local overrides exist.

Choose a default initial branch name

init.defaultBranch main tells future git init operations which initial branch name to use. It improves consistency with many current hosts and tutorials. A team may use another convention; project policy wins over personal preference.

The setting does not rename existing branches, change a cloned repository, or create any repository now. It only supplies a default when you initialize one later.

Audit the effective configuration

git config --get user.name
git config --get user.email
git config --get init.defaultBranch

# See effective values, their scope, and the file that supplied each one
git config --list --show-origin --show-scope

The three --get commands answer “what value will Git use?” The final command answers “where did every value come from?” That second question is essential when a local override, old dotfile, managed policy, or second installation creates surprising behavior.

  1. VALUE
    Read one effective setting

    Use git config --get user.email when you need a precise answer without a large list.

  2. SCOPE
    Identify its level

    --show-scope distinguishes system, global, local, worktree, and command sources.

  3. ORIGIN
    Identify its file

    --show-origin shows which configuration file supplied the entry.

  4. INTENT
    Keep only deliberate values

    Do not change unrelated settings merely because an old setup checklist mentioned them.

QUICK CHECK

Test what you learned

Which configuration scope normally overrides a matching global value inside one repository?

Avoid cargo-cult configuration

Older setup lists often include dozens of commands for line endings, pull behavior, credential storage, aliases, colors, and editors. Each setting encodes a policy. Set it only when you understand the problem it solves.

Line endings

Do not change core.autocrlf blindly. Cross-platform repositories should document their policy, often with .gitattributes.

Credentials

Do not store tokens in plain-text configuration. Use a supported credential manager or SSH workflow when remotes begin.

Aliases

Learn the real commands before hiding them behind personal shorthand that teammates cannot recognize.

Pull strategy

Merge, rebase, and fast-forward policies affect history. Choose after those graph operations are understood.

Troubleshoot from evidence

Git is not found

Inspect installation and PATH

  • Open a fresh terminal.
  • Confirm the installer completed.
  • Check the documented executable directory.
  • Restart an editor opened before installation.
Identity is wrong

Inspect value, scope, and origin

  • Read user.name and user.email.
  • Include --show-origin --show-scope.
  • Look for a local override.
  • Correct the intended scope, not every file.

If two terminals run different Git versions, compare their executable paths and environment. Reinstalling repeatedly can make this worse by adding more candidates without clarifying which one wins.

Independent lab: produce a setup report

On your own machine, install Git only if verification shows it is missing. Then configure deliberate global values and create a short report containing:

  • The output of git --version.
  • The executable path from command -v git or where.exe git.
  • Your chosen author name.
  • Whether you used a public, work, or account-specific no-reply email—do not paste a private address into a shared report.
  • The effective initial branch default.
  • The origin and scope files that supplied those three settings.
Definition of done

You can explain where Git came from, who updates it, which executable runs, what identity future commits will publish, and why each configured value exists. “The commands ran” is not enough.

Lesson review

A reliable Git setup has evidence. Install from a trustworthy source, verify both version and path, configure a deliberate public commit identity, choose a default initial branch, and inspect configuration with scope and origin. Keep authorship separate from authentication, and avoid settings whose policy you cannot explain.

  • I can verify both the Git version and executable path in my real working terminal.
  • I understand that commit identity is public metadata, not GitHub authentication.
  • I can choose global or local scope based on the intended reach of a setting.
  • I know what init.defaultBranch changes and what it does not change.
  • I can trace an effective setting to its scope and origin before modifying it.

For platform-specific authentication and GitHub connection steps beyond this lesson’s scope, use the complete Git and GitHub setup guide.

KNOWLEDGE CHECK

Check the Git setup model

Answer every question before checking. A correct setup is one you can inspect and explain.

01What should you verify immediately after installing Git?
02What do user.name and user.email control?
03Which scope is usually appropriate for your normal personal identity and defaults?
04A local repository email differs from your global email. Which value will Git use there?
05What does init.defaultBranch affect?
06Why use git config --list --show-origin --show-scope?
07Which email is appropriate when you do not want a personal address in public commit history?
PREVIOUS LESSONGit vs GitHub
NEXT LESSON · PLANNEDGit Working Tree
ON THIS PAGEInstall Git and Configure IdentityLesson mapBefore installingWindowsmacOSLinuxVerify GitCommit identityEmail privacyConfig scopesDefault branchAudit configAvoid cargo cultTroubleshootingIndependent labLesson reviewKnowledge check
Course contents