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
Which command creates a new, empty Git repository in the current folder?
- git init
- git clone
- git commit
- 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.
Which commands can change which branch you are working on or create a branch?
- git switch
- git checkout
- git log
- git status
- 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: 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.
