0
0
Gitdevops~5 mins

git cherry-pick a single commit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the git cherry-pick command do?
It applies the changes introduced by a specific commit from one branch onto the current branch.
Click to reveal answer
beginner
How do you cherry-pick a single commit with hash abc123?
Use the command git cherry-pick abc123 while on the target branch.
Click to reveal answer
intermediate
What should you do if a conflict occurs during git cherry-pick?
Manually resolve the conflicts, then run git cherry-pick --continue to finish.
Click to reveal answer
intermediate
Can git cherry-pick be used to apply multiple commits at once?
Yes, by specifying a range of commits or multiple commit hashes, but for a single commit, just use its hash.
Click to reveal answer
advanced
What happens if you cherry-pick a commit that is already in the current branch?
Git typically aborts because it would result in an empty commit (changes already present), unless --allow-empty is used to create a duplicate with a new hash, which can cause confusion.
Click to reveal answer
What is the purpose of git cherry-pick?
ATo apply a specific commit from another branch to the current branch
BTo delete a commit from the history
CTo merge two branches automatically
DTo create a new branch
Which command applies commit abc123 to your current branch?
Agit merge abc123
Bgit cherry-pick abc123
Cgit checkout abc123
Dgit revert abc123
If a conflict happens during cherry-pick, what is the next step?
AResolve conflicts manually then run <code>git cherry-pick --continue</code>
BIgnore and continue
CAbort the cherry-pick with <code>git cherry-pick --abort</code>
DDelete the branch
Can git cherry-pick create duplicate commits?
ANo, it prevents duplicates
BOnly on merge commits
CYes, it creates a new commit with a new hash
DOnly if you use <code>--force</code>
Which command aborts a cherry-pick in progress?
Agit revert
Bgit reset --hard
Cgit merge --abort
Dgit cherry-pick --abort
Explain how to cherry-pick a single commit from another branch and what to do if conflicts occur.
Think about the steps from switching branches to finishing the cherry-pick.
You got /4 concepts.
    Describe the risks or issues that can happen when cherry-picking commits.
    Consider what happens if the same changes exist or conflicts arise.
    You got /3 concepts.