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'):
-
Check commits availability (just to ensure):
svn diff -c 13,666 https://fullpathtoyourproject/branches/_from_
-
Swith on branch to:
svn sw https://fullpathtoyourproject/branches/_to_
-
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.
- Have a local checkout of the branch to which you want to merge a range of revisions from a source branch.
- Right Click inside root folder --> TortoiseSVN --> Merge
- By default, "Merge a range of revisions" is clicked.
- Click Next
- Enter the URL to merge from
- Enter the specific range of revisions you want to merge
- One can also click Show log and select the desired revision or range of revisions
- Click Test Merge to check if it merges desired revisions/files.
- Click merge