jcs
jcs

Reputation: 639

Difference between cherry-pick commit methods in Visual Studio 2017

To cherry-pick commits in Visual Studio I usually right-click the origin branch, click in "View History" and cherry-pick the commits I want to merge to the currently checked out branch. What's the difference when you just right-click the origin branch and click in "Cherry-pick"? enter image description here

Upvotes: 4

Views: 13796

Answers (2)

pierre
pierre

Reputation: 1

Both may be used to cherry-pick but the two alternatives differ in how merge conflicts are handled. More specifically, the View History then Cherry-Pick may ask you to handle fewer merge conflicts while the "direct" Cherry-Pick may ask you to do more.

Upvotes: -1

Romain Valeri
Romain Valeri

Reputation: 22017

Cherry-picking deals with commits, and disregards any branch consideration. Any commit can be cherry-picked if the ref is known somewhere in the repo tree.

The two features you're comparing here are just presentation alternatives. In terms of interface building, VisualStudio designers chose to allow cherry-picking in different ways, but under the hood a cherry-pick is a cherry-pick.

Only things that matter (when you cherry-pick) are

  1. the position of HEAD (which will be the new commit's parent)
  2. the commit cherry-pick points to.

More specifically, for the upper feature you're highlighting ("Cherry-pick"), it doesn't show the hash of the commit you'll cherry-pick, but it's implied by design to be the tip commit (the last) of the branch you just right-clicked and displayed the contextual actions.

(As eftshift0 duly noted below, this mimicks CLI's behaviour of feeding a branch ref to cherry-pick, in which case it's resolved to its tip commit.)

Upvotes: 5

Related Questions