Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does the git cherry-pick command do?
It copies a specific commit from one branch and applies it to another branch without merging the entire branch.
Click to reveal answer
beginner
Why is cherry-pick useful in managing bug fixes?
Because it allows you to apply a bug fix from one branch directly to another branch without merging unrelated changes.
Click to reveal answer
intermediate
How does cherry-pick help in selective feature updates?
It lets you pick only the commits related to a feature you want to add, avoiding bringing in other changes from the source branch.
Click to reveal answer
beginner
What is a real-life example of using cherry-pick?
Imagine you fixed a typo in the main branch but want the fix in the release branch too. Cherry-pick lets you copy just that fix without merging everything else.
Click to reveal answer
intermediate
Can cherry-pick cause conflicts? Why?
Yes, if the changes in the commit conflict with the target branch's code, you will need to resolve conflicts manually.
Click to reveal answer
What is the main purpose of git cherry-pick?
ATo merge two branches completely
BTo create a new branch
CTo delete a commit from history
DTo apply a specific commit from one branch to another
✗ Incorrect
Git cherry-pick copies a specific commit from one branch and applies it to another without merging all changes.
When is cherry-pick most useful?
AWhen you want to copy all changes from one branch
BWhen you want to delete a branch
CWhen you want to apply only one or a few commits selectively
DWhen you want to reset a branch to an earlier state
✗ Incorrect
Cherry-pick is used to apply specific commits, not entire branches.
What should you do if cherry-pick causes conflicts?
AManually resolve the conflicts before completing cherry-pick
BRestart your computer
CDelete the branch
DIgnore the conflicts and continue
✗ Incorrect
Conflicts must be resolved manually to complete the cherry-pick process.
Which command applies a single commit from another branch?
Agit cherry-pick
Bgit merge
Cgit rebase
Dgit branch
✗ Incorrect
Git cherry-pick applies a single commit from another branch.
Cherry-pick is useful for:
ADeleting commits
BApplying bug fixes to multiple branches
CCreating new branches
DViewing commit history
✗ Incorrect
Cherry-pick helps apply specific fixes or features to other branches without merging all changes.
Explain in your own words why git cherry-pick is useful in managing code changes.
Think about copying just one change instead of everything.
You got /4 concepts.
Describe a situation where you would use git cherry-pick instead of git merge.
Imagine fixing a typo in one branch and wanting it in another without all other changes.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the git cherry-pick command?
easy
A. To merge two branches completely
B. To create a new branch from a commit
C. To delete a branch safely
D. To copy specific commits from one branch to another
Solution
Step 1: Understand cherry-pick function
git cherry-pick copies individual commits, not whole branches.
Step 2: Compare with other commands
Merging combines all changes; cherry-pick selects specific commits only.
Final Answer:
To copy specific commits from one branch to another -> Option D
2. Which of the following is the correct syntax to cherry-pick a commit with hash abc123?
easy
A. git pick abc123
B. git cherry-pick abc123
C. git cherry abc123
D. git commit cherry abc123
Solution
Step 1: Recall cherry-pick syntax
The correct command is git cherry-pick <commit-hash>.
Step 2: Check options for syntax errors
The incorrect options use invalid git commands or wrong order such as 'git pick', 'git cherry', or 'git commit cherry'.
Final Answer:
git cherry-pick abc123 -> Option B
Quick Check:
Correct syntax = git cherry-pick [OK]
Hint: Use full command: git cherry-pick commit_hash [OK]
Common Mistakes:
Using 'git cherry' instead of 'git cherry-pick'
Omitting 'pick' keyword
Mixing cherry-pick with commit command
3. Given the following scenario: git log --oneline on branch feature shows: 1a2b3c Fix typo in README 4d5e6f Add new login feature
You run git checkout main and then git cherry-pick 4d5e6f. What will happen on the main branch?
medium
A. No commits are copied, cherry-pick fails
B. Both commits are copied to main
C. Only the 'Add new login feature' commit is copied to main
D. The entire feature branch is merged into main
Solution
Step 1: Identify the commit cherry-picked
The command cherry-picks commit 4d5e6f which is 'Add new login feature'.
Step 2: Understand cherry-pick effect on main
Only the specified commit is copied; other commits remain unchanged.
Final Answer:
Only the 'Add new login feature' commit is copied to main -> Option C
Quick Check:
Cherry-pick copies single commit [OK]
Hint: Cherry-pick copies one commit by hash [OK]
Common Mistakes:
Assuming all commits from feature branch copy
Thinking cherry-pick merges branches
Believing cherry-pick fails without conflicts
4. You tried to cherry-pick a commit but got a conflict error. What is the best way to fix this?
medium
A. Manually resolve the conflict, then run git cherry-pick --continue
B. Abort the cherry-pick with git cherry-pick --abort and try again
C. Delete the branch and recreate it
D. Run git merge --abort to fix cherry-pick conflicts
Solution
Step 1: Understand cherry-pick conflict handling
When conflicts occur, you must manually fix them in files.
Step 2: Continue cherry-pick after resolving conflicts
After fixing, run git cherry-pick --continue to finish the process.
Final Answer:
Manually resolve the conflict, then run git cherry-pick --continue -> Option A
Quick Check:
Fix conflicts + cherry-pick continue [OK]
Hint: Fix conflicts manually, then git cherry-pick --continue [OK]
Common Mistakes:
Using git merge commands to fix cherry-pick conflicts
Aborting without trying to resolve conflicts
Deleting branches unnecessarily
5. You have a bug fix commit on branch hotfix that you want to apply to both main and develop branches without merging all changes from hotfix. What is the best approach?
hard
A. Use git cherry-pick to copy the bug fix commit to both branches
B. Merge hotfix into main and develop
C. Rebase hotfix onto main and develop
D. Create a patch file and apply it manually
Solution
Step 1: Identify the need to apply a single commit selectively
You want only the bug fix commit, not all changes from hotfix.
Step 2: Choose cherry-pick for selective commit copying
git cherry-pick copies specific commits to multiple branches without merging entire branches.
Final Answer:
Use git cherry-pick to copy the bug fix commit to both branches -> Option A
Quick Check:
Cherry-pick = selective commit copy [OK]
Hint: Cherry-pick copies single commits to multiple branches easily [OK]