0
0
Gitdevops~20 mins

Why cherry-pick is useful in Git - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cherry-pick Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use git cherry-pick?

Which situation best explains why git cherry-pick is useful?

ATo delete a commit from the history permanently
BTo merge all changes from one branch into another, including all commits
CTo apply a specific commit from one branch onto another without merging the entire branch
DTo create a new branch from a specific commit
Attempts:
2 left
💡 Hint

Think about applying only one change, not all changes.

💻 Command Output
intermediate
2:00remaining
Output of git cherry-pick command

What is the output of this command if the cherry-pick is successful?

git cherry-pick 9fceb02
Afatal: bad revision '9fceb02'
B
[master 1a2b3c4] Fix typo in README
 Date: Thu Apr 1 12:00:00 2024 +0000
 1 file changed, 1 insertion(+), 1 deletion(-)
Cerror: could not apply 9fceb02... Fix typo in README
DAlready up to date.
Attempts:
2 left
💡 Hint

Successful cherry-pick shows commit info and changes summary.

Troubleshoot
advanced
3:00remaining
Resolving conflicts during cherry-pick

You run git cherry-pick abc123 but get a conflict error. What is the best next step?

AEdit the conflicting files to fix conflicts, then run <code>git cherry-pick --continue</code>
BRun <code>git cherry-pick --abort</code> to cancel the cherry-pick and lose changes
CRun <code>git reset --hard</code> to discard all changes and continue cherry-pick
DRun <code>git merge --continue</code> to finish the cherry-pick
Attempts:
2 left
💡 Hint

Conflicts need manual fixing before continuing.

🔀 Workflow
advanced
2:00remaining
Cherry-pick in a hotfix workflow

In a hotfix workflow, you fix a bug on the hotfix branch and want to apply the fix to develop without merging all hotfix changes. What command do you use?

Agit merge hotfix
Bgit checkout develop && git pull
Cgit rebase develop hotfix
Dgit cherry-pick <commit-hash-of-fix>
Attempts:
2 left
💡 Hint

You want only the bug fix commit, not the whole branch.

Best Practice
expert
3:00remaining
Best practice when cherry-picking multiple commits

You need to cherry-pick several commits from one branch to another. What is the best practice?

ACherry-pick commits in the original order to avoid conflicts and maintain history
BUse <code>git merge</code> instead of cherry-pick for multiple commits
CSquash all commits into one before cherry-picking
DCherry-pick each commit one by one in any order
Attempts:
2 left
💡 Hint

Order matters to keep changes consistent.