Detailed description of SVN branch and merge---command line

Source: Internet
Author: User

One, what is the use of SVN branching and merging?

For SVN, but familiar with the SVN branch, I think not much. Because in general, there is no need to do the SVN branch, in fact, there is no necessity. Let me give you a few examples of how to use the SVN branch:

1, larger than the project. Relatively large projects, in general, will be divided into several stages to finish. Like what five-year plan. At some stage, I set up a branch to be a backup. In case of future development of the next phase of things, when there is a fatal error, I can also take this branch out and then use.

2, the project to develop new things, but do not want to conflict with the main, set up a branch, as a separate development branch. This is also done for the purpose of clarifying responsibility. If something is wrong, check it out.

Second, create the SVN branch

Before you talk about creating a branch, please refer to Linux SVN installation and configuration for the installation and configuration of SVN, not in conjunction with Apache

1. Create a Code folder main

[Email protected] repos]# pwd
/home/zhangy/checkout/repos
[[email protected] repos]# svn Add./main
A Main
A main/test.php
[[email protected] repos]# svn commit./main-m "Test"
Adding Main
Adding main/test.php
Transmitting file data.
Committed Revision 5.

2, creating a branch

[[email protected] repos]# svn copy svn://127.0.0.1/repos/main svn://127.0.0.1/repos/branch-m "test"

Committed revision 6.

3. View branching status

[Email protected] repos]# svn log-v./branch/test.php
------------------------------------------------------------------------
R6 | Zhangy | 2010-10-24 19:59:35 +0800 (Sun, Oct 2010) | 1 line
Changed paths:
A/branch (From/main:5)

Test
------------------------------------------------------------------------
R5 | Zhangy | 2010-10-24 19:53:20 +0800 (Sun, Oct 2010) | 1 line
Changed paths:
A/main
a/main/test.php

Test
------------------------------------------------------------------------

4, the note between the matters:

A), creating a branch, which can only be done within the same warehouse, is not possible across warehouses. Will prompt Svn:no repository found in ' svn://127.0.0.1 '

b), when you create a branch, note that you add a comment, or the following error is reported.

[Email protected] repos]# svn cp svn://127.0.0.1/repos/main Svn://127.0.0.1/repos/branch
Svn:could not use external editor to fetch log message; Consider setting the $SVN _editor environment variable or using the--message (-m) or--file (-f) options
Svn:none of the environment variables svn_editor, VISUAL or EDITOR is set, and no ' Editor-cmd ' run-time configuration op tion was found

Three, merging branches

Here is an example of how to merge a branch. I think that through the example, the most can learn something, I Boven in my emphasis on this point.

1, modify the file in main to submit to the SVN server side, so that the main code and branch branch of the code is not the same.

2. Synchronize the files in the main file into the branch branch

View copy print?
  1. [[email protected] branch]# pwd //Whether in the branch folder
  2. /home/zhangy/checkout/repos/branch
  3. /**
  4. Synchronize the changes in main to the branch branch
  5. If it is the specified version can be svn merge-r 9:10 svn://127.0.0.1/repos/main
  6. */
  7. [[Email protected] branch]# svn merge svn://127.0.0.1/repos/main
  8. ---merging R6 through R8 into '. ': //Update to 8th version
  9. U test.php
  10. [[Email protected] branch]# svn log-v test.php //View test.php, from below we can see that the branch version has not become what?
  11. ------------------------------------------------------------------------
  12. R6 | Zhangy | 2010-10-24 19:59:35 +0800 (Sun, Oct 2010) | 1 line
  13. Changed paths:
  14. A/branch (From/main:5)
  15. Test
  16. ------------------------------------------------------------------------
  17. R5 | Zhangy | 2010-10-24 19:53:20 +0800 (Sun, Oct 2010) | 1 line
  18. Changed paths:
  19. A/main
  20. a/main/test.php
  21. Test
  22. ------------------------------------------------------------------------
  23. [[Email protected] branch]# svn commit-m "test" //Submit
  24. Sending.
  25. Sending test.php
  26. Transmitting file data.
  27. Committed Revision 9.
  28. [[Email protected] branch]# svn log-v test.php //Yes No because there is no commit, a new version will be generated after submission
  29. ------------------------------------------------------------------------
  30. R9 | Zhangy | 2010-10-24 20:52:22 +0800 (Sun, Oct 2010) | 1 line
  31. Changed paths:
  32. M/branch
  33. m/branch/test.php
  34. Test
  35. ------------------------------------------------------------------------
  36. R6 | Zhangy | 2010-10-24 19:59:35 +0800 (Sun, Oct 2010) | 1 line
  37. Changed paths:
  38. A/branch (From/main:5)
  39. Test
  40. ------------------------------------------------------------------------
  41. R5 | Zhangy | 2010-10-24 19:53:20 +0800 (Sun, Oct 2010) | 1 line
  42. Changed paths:
  43. A/main
  44. a/main/test.php
  45. Test
  46. ------------------------------------------------------------------------

The merger here is basically over.

3, the above said is the backbone of the file synchronization to the branch, the branch of the content synchronization step trunk is the same, upside down on the line.

4, all and the time, there may be conflicts, look below

View copy print?
  1. [[Email protected] main]# svn merge svn://127.0.0.1/repos/branch
  2. Conflict discovered in ' test.php '. //prompt conflict
  3. Select: (P) postpone, (DF) Diff-full, (e) Edit, //Here you choose how to handle
  4. (MC) Mine-conflict, (TC) Theirs-conflict,
  5. (s) Show All Options:p
  6. ---merging R7 through R12 into ' test.php ':
  7. C test.php
  8. Summary of conflicts:
  9. Text conflicts:1 //Although there is a conflict, but still can be synchronized, also indicates that the synchronization was successful.
  10. ---/tmp/tempfile.2.tmp Sun Oct 24 21:02:11 2010
  11. + + +. Svn/tmp/test.php.tmp Sun Oct 24 21:02:11 2010
  12. @@ -0,0 +1,9 @@
  13. +<<<<<<<. Working
  14. +asdfadfadfadf
  15. +111111111111111
  16. +=======
  17. +asdfadfadfadf
  18. +111111111111111
  19. +222222222222
  20. +
  21. +>>>>>>>. Merge-right.r12
1

Detailed description of SVN branch and merge---command line

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.