Subversion: How to merge a specific commit

2020-05-18 04:46发布

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?

标签: svn merge
4条回答
女痞
2楼-- · 2020-05-18 05:17

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
查看更多
迷人小祖宗
3楼-- · 2020-05-18 05:18

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_

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

查看更多
家丑人穷心不美
4楼-- · 2020-05-18 05:22

You can merge the commits you want with the revision number.

查看更多
狗以群分
5楼-- · 2020-05-18 05:23

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.

查看更多
登录 后发表回答