As part of an “introduction to git” training day I’m running I prepared a quiz for the group. After all, what else would you do over lunch?
I thought I was okay with git, but the old adage is true: if you really want to learn something, get a student. I found out a lot about git’s nooks and crannies in the course of preparing the material. See how you do; it’s not meant to be tricky. Answers next week…
Basic operations
- Describe the working directory, staging area and repository.
- What two things does git rm myfile do?
- Where do the following commands get myfile from? (And in case you’re as clever as one participant: No, myfile is not a branch)
git checkout myfile git checkout HEAD -- myfile git checkout 9bffd0 -- myfile
- If git status says “Nothing to commit”, what’s in the staging area?
Branches and tags
- What’s a branch, really?
- If you want to continue from where you are now but on a new branch, what are the two steps to take (which can be rolled into one command)?
- How do you switch to another branch?
- Branches and tags are very similar. Why? And what’s the difference?
Remote branches
- What does alice/rel-1200 mean as a branch name?
- What can’t you do with a remote branch (e.g. bob/refactored)?
- If I fetch origin/master and then someone else pushes their master to origin, what happens to my origin/master?
Merging
- When does a merge conflict occur?
- What is the last step of a merge if there no conflicts?
- How do you signal you’ve resolved a conflict in a file?
- What’s a fast-forward merge?
Pushing and pulling
- What two operations does git pull do?
- Which branches will git pull origin pull down?
- Which branches will git push origin push up?
Rebasing
- Why is rebasing called “rebasing”?
- If you git rebase origin/master what line of commits gets moved where?
- How do you signal a conflict resolution on a file during a rebase?
- How do you continue the rebase after that?
- How do fetch and rebase in one command?
- What flag prevents a multiway (traditional) merge?
- When a commit moves as part of a rebase, what changes and what stays the same?
- What’s the danger in rebasing other people’s work?