Bitzu

GH-900 ยท Version control and Git

Everyday Git commands

git init, clone, status, add, commit, branch, switch/checkout, merge and log: what each does and in what order they are used.

Key points

  • git init starts a repository; git clone copies one.
  • git status shows changes, git add stages them, git commit -m records them.
  • git branch lists or creates branches; git switch (or git checkout) changes branch.
  • git merge combines branches; git log shows history.

Source: https://git-scm.com/docs/git-commit

Practice questions

Single choice

Which command creates a new, empty Git repository in the current folder?

  1. git init
  2. git clone
  3. git commit
  4. git status
Show answer

Answer: A. git init

git init initializes a repository. git clone copies an existing one, git commit records staged changes, and git status only reports state.

Select all that apply

Which commands can change which branch you are working on or create a branch?

  1. git switch
  2. git checkout
  3. git log
  4. git status
  5. git branch
Show answer

Answer: A. git switch, B. git checkout, E. git branch

git switch and git checkout change branches, and git branch can create one. git log only reads history and git status only reports state.

True or false

True or false: git commit -a also includes brand-new files that Git has never tracked.

Show answer

Answer: False

False. The -a option stages modified and deleted tracked files only. New files must first be added with git add.

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