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

Interview Questions: Moving Work

Stash, cherry-pick and clone.

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

The last tricky questions are about moving work around, between branches, and between repositories.

Interview Questions: Moving Work
From the video: Interview Questions: Moving Work
  • Moving work around
  • Between branches
  • Between repositories

Stash or commit?

Question seventeen. When would you stash instead of commit? Stash is for unfinished work you need to put aside quickly, for example to switch branches for an urgent fix. A commit is a permanent step in history. If the work makes sense on its own, commit it. If it's half done, stash it.

git stash

  • Unfinished work
  • Temporary shelf
  • Not in history

git commit

  • A complete step
  • Permanent
  • Part of history

When would you cherry-pick?

Question eighteen. When would you use cherry pick? To copy one specific commit to another branch, without merging the whole branch. A common example is copying a bug fix from main into an older release branch. Mention that the copy gets a new hash.

Copiesone commit
Withoutmerging everything
Examplefix → release branch
Resulta new hash

Clone versus fork?

Question nineteen. What's the difference between a clone and a fork? A clone is a Git operation. It copies a repository to your computer. A fork is a GitHub feature. It copies a repository to your GitHub account. To contribute to open source, you usually fork first, then clone your fork.

Clone

  • Git command
  • Copy to your computer
  • git clone <url>

Fork

  • GitHub feature
  • Copy to your account
  • Click Fork

Summary

Stash half-done work, cherry pick single commits, and remember that a fork lives on GitHub, while a clone lives on your computer. Next, a final quiz round.

Key takeaways
  • Stash: half-done
  • Cherry-pick: one commit
  • Fork: GitHub, clone: computer
Next up: Quick-Fire Quiz — test yourself