What does the git cherry-pick command do?

What does the git cherry-pick command do?

a) Applies a specific commit from one branch to another
b) Deletes a commit from the history
c) Resets the current branch to a specific commit
d) Combines multiple branches

Answer:

a) Applies a specific commit from one branch to another

Explanation:

The git cherry-pick command applies a specific commit from one branch to another without merging the entire branch. This is useful when you want to bring specific changes (commits) into your branch without pulling in unrelated work.

For example, git cherry-pick abc123 will apply the commit with hash abc123 to the current branch.

This command is useful for selectively incorporating changes from other branches.

Reference:

Top 100 Git and GitHub MCQ Questions and Answers

Scroll to Top