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
What is a commit in Git?
- A snapshot of the project recorded in history with author, time and message
- A copy of the repository stored on a remote server
- A separate line of development
- 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.
Which statements about branches and HEAD are correct?
- A branch is a pointer to a commit
- HEAD indicates the commit or branch currently checked out
- Creating a branch duplicates every file on disk
- HEAD is the name of the remote server
- 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: 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.
