Learning objectives
By the end of this module, you should be able to:
- Verify the Git client.
- Set repository-local identity without changing unrelated repositories.
- Use git help and config origin information.
Identity is commit metadata
user.name and user.email are written into new commit metadata. They are not a GitHub login mechanism and do not authenticate network access.
Configuration has scopes
Git reads system, global and repository-local configuration. A local setting can override a global setting for one repository. git config --show-origin helps explain where a value came from.
Use the documentation
git help <command> and git <command> -h are safer than guessing destructive flags. Modern Git separates branch switching and file restoration into git switch and git restore, while git checkout remains available.
Worked examples
See the idea in practice.
Configure a lab-only identity
git --version
git config --local user.name "GNU Learner"
git config --local user.email "learner@example.invalid"
git config --show-origin --get user.name
- --local writes .git/config in the current repository.
- Identity affects future commits in this repository.
Hands-on lab
Lab — Configure a repository safely
Goal: Set local author metadata and verify exactly where it is stored.
Before you start
- Git 2.23 or newer is recommended so the labs can use git switch and git restore.
- Run labs in a disposable working directory; the included validator creates and removes its own temporary repository.
STEP 1Reuse or create a lab repository
mkdir -p ~/gnu-git-labs/module02 && cd ~/gnu-git-labs/module02
git init -b main
STEP 2Set local identity
git config --local user.name "GNU Learner"
git config --local user.email "learner@example.invalid"
STEP 3Inspect origins
git config --show-origin --get user.name
git config --show-origin --get user.email
STEP 4Open concise help
git status -h | head
Verify
- user.name and user.email resolve from .git/config.
- git status help renders successfully.
Expected outcome
- Only the lab repository receives these local identity values.
If it fails
- If Git says not in a repository, cd into module02 first.
- Avoid changing --global values on managed workstations unless that is intentional.
Real-world connectionProduction build systems often set an explicit bot identity locally so automated commits are attributable and reproducible.
Avoid these traps
Common mistakes
- Assuming user.email authenticates to GitHub.
- Using --global when a repository-specific identity is intended.
- Copying an unfamiliar destructive command without reading its help.
Knowledge check
Can you explain it without looking back?
Open each answer only after you have tried to answer the question yourself.
1Does user.email prove GitHub authentication?
No. It is commit metadata.
2Which scope affects only the current repository?
Repository-local configuration.
3How can you see where a config value came from?
git config --show-origin.