Bitzu

GH-900 ยท Version control and Git

Repositories, commits and branches

What a repository, working directory, staging area, commit, branch and HEAD are, and how commits form history.

Key points

  • A repository holds your project files and their full history.
  • You edit files in the working directory, choose what to record by adding them to the staging area, then create a commit: a snapshot with author, time, message and a link to its parent.
  • A branch is a movable pointer to a commit that lets a line of work diverge, and HEAD marks the commit or branch you currently have checked out.

Source: https://docs.github.com/en/get-started/using-git/about-git

Practice questions

Single choice

What is a commit in Git?

  1. A snapshot of the project recorded in history with author, time and message
  2. A copy of the repository stored on a remote server
  3. A separate line of development
  4. The area where changes wait before being recorded
Show answer

Answer: A. A snapshot of the project recorded in history with author, time and message

A commit is a recorded snapshot with metadata and a parent link. It is not a branch, a remote server, or the staging area.

Select all that apply

Which statements about branches and HEAD are correct?

  1. A branch is a pointer to a commit
  2. HEAD indicates the commit or branch currently checked out
  3. Creating a branch duplicates every file on disk
  4. HEAD is the name of the remote server
  5. New commits on a branch move that branch forward
Show answer

Answer: A. A branch is a pointer to a commit, B. HEAD indicates the commit or branch currently checked out, E. New commits on a branch move that branch forward

A branch is a lightweight pointer to a commit, and HEAD indicates what is checked out. A branch is not a full copy of the files, and HEAD is not a remote server.

True or false

True or false: saving a file in your editor automatically adds it to the Git history.

Show answer

Answer: False

False. Saving only changes the working directory. You must stage the change and create a commit to record it in history.

Practice 8 questions on this topic in Bitzu

Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.

Download on the App StoreGet it on Google Play

More GH-900 topics in this module