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.
A reliable setup has four proofs
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 gitVersion 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.
Install Git on Windows
- 01Use Git for Windows
Download the maintained installer from git-scm.com. It includes Git, Git Bash, OpenSSH, and Git Credential Manager.
- 02Choose 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.
- 03Keep a practical PATH option
The recommended option that exposes Git to command-line and third-party tools works for most learners.
- 04Open 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 gitInstall 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 gitPackage 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.
One understood executable
git --versionprints a version.- The path matches your chosen installation.
- A fresh terminal reports the same result.
- Your editor terminal agrees.
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.
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 mainReplace 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.
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.exampleIn 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.
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-scopeThe 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.
VALUERead one effective settingUse
git config --get user.emailwhen you need a precise answer without a large list.SCOPEIdentify its level--show-scopedistinguishes system, global, local, worktree, and command sources.ORIGINIdentify its file--show-originshows which configuration file supplied the entry.INTENTKeep only deliberate valuesDo not change unrelated settings merely because an old setup checklist mentioned them.
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
Inspect installation and PATH
- Open a fresh terminal.
- Confirm the installer completed.
- Check the documented executable directory.
- Restart an editor opened before installation.
Inspect value, scope, and origin
- Read
user.nameanduser.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 gitorwhere.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.
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.defaultBranchchanges 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.