Subversion: How to merge a specific commit

Solution 1:

What you want to accomplish is usually called cherrypicking in version control systems.

Say that you want to merge revisions 345, 364 and 377 from your branch to trunk, you will do the following at the top level directory of a clean working copy of trunk:

svn merge -c345,364,377 ^/_your_branch_

on Windows cmd add quotes around the branch name:

svn merge -c345,364,377 "^/_your_branch_"

You can find more information in the corresponding section of the SVN Book.

Solution 2:

Just to extend Yannick's answer.
When you can merge one/few specific commits from one to another branch you need(for example need merge commits r13 and r666 from branch 'from' into branch 'to'):

  1. Check commits availability (just to ensure):

    svn diff -c 13,666 https://fullpathtoyourproject/branches/_from_
    
  2. Swith on branch to:

    svn sw https://fullpathtoyourproject/branches/_to_
    
  3. Merge commits

    svn merge -c 13,666 https://fullpathtoyourproject/branches/_from_
    

If you need get 'fullpathtoyourproject' just type:

svn info

In section URL you will see this path.

I prefer to use FULL url/path, cause personally relative path did not work for me on some projects.

Solution 3:

If one has TortoiseSVN installed, below are the steps to merge a range of revisions from a branch to the other.

  1. Have a local checkout of the branch to which you want to merge a range of revisions from a source branch.
  2. Right Click inside root folder --> TortoiseSVN --> Merge
  3. By default, "Merge a range of revisions" is clicked.
  4. Click Next
  5. Enter the URL to merge from
  6. Enter the specific range of revisions you want to merge
  7. One can also click Show log and select the desired revision or range of revisions
  8. Click Test Merge to check if it merges desired revisions/files.
  9. Click merge