0
0
Gitdevops~20 mins

git cherry-pick a single commit - Practice Problems & Coding Challenges

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!
💻 Command Output
intermediate
1:30remaining
Output of cherry-pick with a valid commit hash
What is the output when you run git cherry-pick 1a2b3c4 on a branch where the commit 1a2b3c4 exists and applies cleanly?
Aerror: could not apply 1a2b3c4... Commit message
BFinished one cherry-pick.
Cfatal: bad revision '1a2b3c4'
DAlready up to date.
Attempts:
2 left
💡 Hint
Cherry-pick applies the commit if it can without conflicts.
🧠 Conceptual
intermediate
1:30remaining
Understanding cherry-pick behavior on conflicts
What happens if you run git cherry-pick abcdef1 and the changes conflict with your current branch?
AGit pauses and asks you to resolve conflicts before continuing.
BGit automatically merges the changes without any message.
CGit deletes the conflicting files.
DGit discards the cherry-pick and leaves the branch unchanged.
Attempts:
2 left
💡 Hint
Cherry-pick stops when conflicts occur.
🔀 Workflow
advanced
2:00remaining
Correct sequence to cherry-pick and resolve conflicts
Arrange the steps in the correct order to cherry-pick a commit and resolve conflicts if they occur.
A1,4,2,3
B2,1,3,4
C1,2,3,4
D1,3,2,4
Attempts:
2 left
💡 Hint
Cherry-pick stops on conflicts, you fix them, stage changes, then continue.
Troubleshoot
advanced
1:30remaining
Error when cherry-picking a non-existent commit
What error message do you get if you run git cherry-pick deadbeef but the commit hash deadbeef does not exist in your repository?
Afatal: bad revision 'deadbeef'
Berror: could not apply deadbeef... Commit message
CAlready up to date.
DFinished one cherry-pick.
Attempts:
2 left
💡 Hint
Git cannot find the commit hash in the repo.
Best Practice
expert
2:00remaining
Best practice to avoid duplicate commits when cherry-picking
Which practice helps avoid duplicate commits when cherry-picking a commit that might already be in your branch history?
ADelete the branch before cherry-picking.
BAlways force push after cherry-pick to overwrite history.
CRun <code>git cherry-pick --abort</code> after every cherry-pick.
DUse <code>git cherry-pick -x</code> to record the original commit hash in the message.
Attempts:
2 left
💡 Hint
Tracking original commit helps identify duplicates.