Git & GitHub Interview Question #60

What happens if a cherry-pick has conflicts?

Undo & Recovery, Tags, Forks, Pull Requests & Code Review Mid-Level Intermediate

Quick Interview Answer

Git pauses the cherry-pick and marks conflicting files for manual resolution. The developer resolves the files, stages them, and runs git cherry-pick --continue.

Detailed Explanation

Git pauses the cherry-pick and marks conflicting files for manual resolution. The developer resolves the files, stages them, and runs git cherry-pick --continue.

If the operation should be canceled, git cherry-pick --abort attempts to restore the pre-cherry-pick state.

Code Example

git status

# Resolve conflicts
git add resolved-file.cs
git cherry-pick --continue

# Or cancel
git cherry-pick --abort