Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subversion: How to merge a specific commit

Tags:

merge

svn

I have some commit on my branches. I want to merge the branches to trunk, but there have some commit that I don't merge to trunk on my branches. How do I do?

like image 558
Clown Avatar asked Jul 19 '12 08:07

Clown


People also ask

How do you merge a specific commit from one branch to another SVN?

Have a local checkout of the branch to which you want to merge a range of revisions from a source branch. By default, "Merge a range of revisions" is clicked. Click Test Merge to check if it merges desired revisions/files.

Can I merge a commit?

Git merging combines sequences of commits into one unified history of commits. There are two main ways Git will merge: Fast Forward and Three way. Git can automatically merge commits unless there are changes that conflict in both commit sequences.


3 Answers

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.

like image 177
Yannick Blondeau Avatar answered Oct 22 '22 10:10

Yannick Blondeau


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.

like image 44
iMysak Avatar answered Oct 22 '22 11:10

iMysak


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
like image 5
Prashanth Avatar answered Oct 22 '22 11:10

Prashanth