Bird
0
0

You run git cherry-pick 9a8b7c6 on branch feature. What happens if the commit 9a8b7c6 changes a file that does not exist on feature?

medium📝 Command Output Q4 of 15
Git - Cherry-Pick and Advanced Merging
You run git cherry-pick 9a8b7c6 on branch feature. What happens if the commit 9a8b7c6 changes a file that does not exist on feature?
AThe commit is applied and the new file is added to <code>feature</code>
BGit throws an error and stops the cherry-pick
CThe commit is skipped automatically
DThe commit is applied but the file remains unchanged
Step-by-Step Solution
Solution:
  1. Step 1: Understand cherry-pick behavior with new files

    If the commit adds a new file, cherry-pick will add that file to the current branch.
  2. Step 2: Confirm no error occurs

    Git does not error if the file is missing; it applies the commit changes including new files.
  3. Final Answer:

    The commit is applied and the new file is added to feature -> Option A
  4. Quick Check:

    Cherry-pick adds new files from commit to branch [OK]
Quick Trick: Cherry-pick adds new files from commits automatically [OK]
Common Mistakes:
  • Expecting errors when files are missing
  • Thinking cherry-pick skips commits
  • Assuming files remain unchanged

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Git Quizzes