Skip to content

Save your first commit

Getting started · Article 1 of 9 · 3 min read

A commit is the unit of everything in Git, so start by making one.

The short version

A repository is a folder Git tracks. A commit is a saved snapshot of your files with a message that says why. You choose what goes into a commit by staging files first.

Details

Git has three places a change can live: your working folder, the staging area, and the history of commits. git add moves a change into the staging area. git commit turns everything staged into a commit.

Try it yourself

mkdir duck-notes
cd duck-notes
git init
echo "Quack" > notes.txt
git add notes.txt
git commit -m "Add first note"
git log --oneline

You should see one line with a short commit id and the message Add first note.

Explain it to the duck

Why does Git make you stage a file before you commit it?

Tested with: Git 2.51.