AI Hints
Home›Git & GitHub Tutorial›Interview Questions 3
Git & GitHub · Lesson 137 of 144

Interview Questions: Tricky Ones

The ones that catch people out.

⏱ 2 min read▶ Video at 2:30:09🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

These questions sound simple, but they catch a lot of people out, because the answer needs one precise idea. Try each one out loud first.

Interview Questions: Tricky Ones
From the video: Interview Questions: Tricky Ones
  • They sound simple
  • They need one precise idea
  • Answer out loud first

What is HEAD?

Question thirteen. What is head? Head is a pointer to where you are right now. Usually it points to a branch, which points to a commit. When head points directly to a commit, instead of a branch, that's called a detached head. Committing there is risky, unless you create a branch.

HEADwhere you are
NormallyHEAD → branch → commit
DetachedHEAD → commit
Fixgit switch -c <name>

What is a fast-forward merge?

Question fourteen. What is a fast forward merge? When the branch you're merging into hasn't moved since the other branch started, Git doesn't need a merge commit. It just moves the branch pointer forward. If both branches have new commits, Git needs a real merge, with a merge commit.

Fast-forward

  • Target hasn't moved
  • Pointer slides forward
  • No merge commit

Three-way merge

  • Both have new commits
  • Combine the work
  • Creates a merge commit

Summary

Head is where you are, and a fast forward just moves the pointer. Next, two more tricky ones.

Key takeaways
  • HEAD = you are here
  • Detached = no branch
  • Fast-forward = no merge commit
Next up: Interview Questions: Remotes and Ignoring — origin, upstream and .gitignore