Copy changes with cherry-pick

VSTS | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015 Update 2

Copy commits from one branch to another using cherry-pick. Unlike a merge or rebase, cherry-pick only brings the changes from the commits you select, instead of all the changes in a branch.

Cherry-pick is a great way to tackle these common problems:

  • Accidentally committing on the wrong branch. Cherry-pick the change(s) over to the correct branch and then reset the original branch to the previous commit.
  • Pulling out a set of commits made in a feature branch so you merge them back to your master branch sooner.
  • Porting in specific commits from the master branch without rebasing your branch.

In this tutorial you learn how to:

  • Cherry-pick a commit

Cherry-pick a commit

  1. Open up Team Explorer and checkout to the branch you want to cherry-pick changes into using the Branches view.
  2. Right-click the branch containing the changes you want and select View History....
  3. Right-click the commit you want to cherry-pick and select Cherry-pick.

    Visual Studio copies the changes made in that commit into a new one on your current branch. Cherry pick from inside Visual Studio

Repeat this process for each commit you need to bring over to your current branch.

Next steps