WeCodeAcademy

Staging and Committing

Saving a snapshot takes two steps. First stage the files you want with git add. Then commit them with a message.

Examplebash
Open in editor »
/ $

After git add, the file is under Changes to be committed. After the commit, the working tree is clean: nothing is waiting to be saved.

git add . stages everything in the folder at once. git commit -am "message" stages changes to already-tracked files and commits in one go.

Quick check

What does `git add` do?

Your turn: write the code

Start a repository, create readme.txt, stage it and commit it with the message "Add readme". Finish with git status, which should show a clean working tree. (Checked on the output of your last command.)

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.