Before this lesson

Use Git 2.35+ and a Bash-compatible terminal, such as Git Bash on Windows. Each complete example creates an independent temporary directory. Run it only in that practice repository. Configuration is repository-local and uses a practice identity. Temporary directories are not automatically removed; clean them up after finishing.

What you will be able to do

Create a local repository and distinguish commits from remote hosting.

Understand the mechanism

Git stores project history locally. GitHub and GitLab are hosting services. Initialization, diffs and commits work without an account or network. A commit records staged content; push transfers relevant commits to a remote.

Choose an installation method from the official Git installation guide and verify it with git --version. This series uses init -b, switch and restore, and consistently targets Git 2.35 or newer. A graphical client does not replace the underlying concepts.

user.name and user.email become commit metadata, not login credentials. Public pushes may expose them. Use an appropriate identity and public or platform-provided privacy address for real work. These examples configure only the temporary repository.

main is a branch name, not a mandatory Git keyword. Commit identifiers depend on content and metadata, so yours will differ from an example. Verify the commit message and status instead.

Runnable example

lab=$(mktemp -d)
cd "$lab"
git init -b main .
git config user.name "Honeysuck Learner"
git config user.email 'learner'@'example.invalid'
git config commit.gpgsign false
git config core.autocrlf false
git --version
printf '# My study notes\n' > README.md
git status --short
git add README.md
git commit -m "Create study notebook"
git log -1 --format=%s
git status --short

Trace and verify

The first status shows ?? README.md for an untracked file. After committing, the message is Create study notebook and the final short status is empty, indicating a clean worktree and index.

Common mistakes and boundaries

git init does not automatically back up every file. Unstaged files are absent from the commit, and repository history is not a substitute for an independent backup. Never place access tokens in identity configuration or commits.

Practice challenge

Add a learning goal, make a second commit and check the number of commits.

Reference solution and reasoning

Append to README.md, inspect git diff, stage it and commit with message Add learning goal. git rev-list --count HEAD should be 2, followed by an empty status.

Further reading