QuizzesCherry-pick — Apply Specific Commits — Concept Check
intermediate
git

Cherry-pick — Apply Specific Commits — Concept Check

Questions on Cherry-pick — Apply Specific Commits. git cherry-pick applies the changes from one or more specific commits onto your current branch, creating new commits with the same diff but different hashes.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Cherry-pick — Apply Specific Commits — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You have a feature branch with multiple commits, but only one commit contains the bug fix you need on the main branch. What is the best approach to apply just this fix?

    • ARebase the feature branch onto the main branch.
    • BMerge the feature branch into the main branch.
    • CCopy the changes manually from the feature branch to the main branch.
    • DUse git cherry-pick with the specific commit hash of the fix.
  2. 2.You are on a release branch and need to apply a hotfix from the main branch. You use git cherry-pick and encounter a conflict. What should you do next?

    • AUse git cherry-pick --skip to bypass the conflict.
    • BResolve the conflict, stage the changes, and run git cherry-pick --continue.
    • CSwitch to the main branch to resolve the conflict.
    • DAbort the cherry-pick and try again later.
  3. 3.A colleague tells you that cherry-picking commits will keep the original commit hashes. What is the truth about commit hashes in cherry-picking?

    • ACherry-picking merges the commit history, retaining hashes.
    • BCherry-picking changes the commit message but not the hash.
    • CCherry-picking retains the original commit hashes.
    • DCherry-picking creates new commits with different hashes.
  4. 4.You want to apply multiple sequential commits from a feature branch to your current branch. Which command should you use?

    • Agit checkout <feature-branch-name>
    • Bgit cherry-pick <oldest-commit-hash>..<newest-commit-hash>
    • Cgit merge <feature-branch-name>
    • Dgit rebase <feature-branch-name>
  5. 5.While cherry-picking a commit, you encounter a merge conflict in a file. What is the correct sequence to resolve this?

    • AEdit the file, stage the changes, and continue the cherry-pick.
    • BEdit the file and commit directly without staging.
    • CSkip the conflicting commit and continue.
    • DAbort the cherry-pick and start over.
  6. 6.You want to apply changes from a commit without creating a new commit immediately. Which option should you use with git cherry-pick?

    • A--continue
    • B--skip
    • C--no-commit
    • D--abort
  7. 7.You need to apply a hotfix from the main branch to a release branch, but also want to keep the history clean without merging all changes. What command should you use?

    • Agit cherry-pick <commit-hash>
    • Bgit checkout main
    • Cgit rebase main
    • Dgit merge main
  8. 8.What happens if you try to cherry-pick a merge commit without specifying a mainline parent?

    • AA new branch is created with the merge commit.
    • BThe cherry-pick proceeds normally without issues.
    • CThe commit is skipped automatically.
    • DAn error occurs, requiring you to specify a mainline parent with -m.