Bitpath

Lesson 2 · Unit 01

Three trees

Working directory, index and HEAD

13 exercisesabout 3 min

What you practise

  • Working directory, index (staging area) and HEAD
  • git add and git commit move content between them
  • Reading git status and git diff vs git diff --staged

Try a question from this lesson

Pick one

The file is edited again after git add. Which version does the commit hold? (git show HEAD:f.txt prints the committed copy.)

shell
git init -q
echo v1 > f.txt
git add f.txt
echo v2 > f.txt
git commit -q -m save
git show HEAD:f.txt

The idea

Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.

Concept

Three places

Git keeps three versions of your project. The working directory is the files you edit. The index, or staging area, is the draft of the next commit. HEAD is the last commit.

git add copies a file from the working directory into the index. git commit turns the whole index into a new commit.

working directory   (files you edit)
      |  git add
      v
index               (next commit's draft)
      |  git commit
      v
HEAD                (last commit)

11 more exercises in the app

  • 3× type the answer
  • 3× multiple choice
  • 1× fill the blanks
  • 2× true or false
  • 1× order the lines
  • 1× match the pairs

Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.

One email when Bitpath is ready to try. Nothing else. Privacy