Beginner lesson 1 of 6

Understand Git: working files, staging, and commits

See how working files, the staging area, and committed history differ in a small Git repository.

Before you start

Imagine keeping a history of a project note. Git records snapshots you choose, rather than saving every edit automatically. A repository contains your files and a .git directory with local history. The working tree is what you can edit; the index (staging area) is the proposed next snapshot; a commit records that snapshot with its parent and message.

Use Git 2.28 or newer in a POSIX shell on macOS/Linux, or Git Bash on Windows. Check git --version; Git's installation page covers setup. Each example starts in a new temporary folder. Keep that folder if you want to revisit your work; none of these commands removes your existing projects. The identity and signing settings below apply only to the practice repository.

Work through the example

Start a scratch repository and create a file:

practice=$(mktemp -d "${TMPDIR:-/tmp}/gitglow-learn.XXXXXX")
sandbox="$practice/project"
mkdir "$sandbox"
cd "$sandbox"
git init -b main
git config --local user.name "Git Learner"
git config --local user.email "learner@example.invalid"
git config --local commit.gpgsign false
printf 'First draft\n' > notes.txt
git status --short

The ?? entry means the file is untracked. Stage the first draft, then edit the working file again:

git add notes.txt
printf 'Second draft\n' >> notes.txt
git diff
git diff --cached
git commit -m "Record first draft"
git status --short

Check the result

The commit contains only First draft. git diff shows the second line still in your working tree; git diff --cached showed the first draft before committing. The final status is M notes.txt: the space means no staged difference, while M means an unstaged modification. A commit does not automatically include edits made after staging.

Try it yourself

Run git show HEAD:notes.txt, then compare it with cat notes.txt. Stage and commit the second line. Both views should then match and git status --short should print nothing.

If something goes wrong

If the folder is not a repository, check pwd and return to the sandbox created above. If the commit has no changes, inspect git diff --cached; Git commits the staging area, not every working file.

Use this workflow in GitGlow

Open the printed sandbox path in GitGlow and choose Changes. Compare pending files with the staged diff before committing. Repository inspection, staging, and commits are Free. History shows the recorded snapshot; later unstaged edits remain in Changes.

Download GitGlow Free

Go deeper with the official Git docs

These references cover command options and behavior beyond this example.