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?
- [[email protected] branch]# pwd //Whether in the branch folder
- /home/zhangy/checkout/repos/branch
- /**
- Synchronize the changes in main to the branch branch
- If it is the specified version can be svn merge-r 9:10 svn://127.0.0.1/repos/main
- */
- [[Email protected] branch]# svn merge svn://127.0.0.1/repos/main
- ---merging R6 through R8 into '. ': //Update to 8th version
- U test.php
- [[Email protected] branch]# svn log-v test.php //View test.php, from below we can see that the branch version has not become what?
- ------------------------------------------------------------------------
- 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
- ------------------------------------------------------------------------
- [[Email protected] branch]# svn commit-m "test" //Submit
- Sending.
- Sending test.php
- Transmitting file data.
- Committed Revision 9.
- [[Email protected] branch]# svn log-v test.php //Yes No because there is no commit, a new version will be generated after submission
- ------------------------------------------------------------------------
- R9 | Zhangy | 2010-10-24 20:52:22 +0800 (Sun, Oct 2010) | 1 line
- Changed paths:
- M/branch
- m/branch/test.php
- Test
- ------------------------------------------------------------------------
- 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
- ------------------------------------------------------------------------
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?
- [[Email protected] main]# svn merge svn://127.0.0.1/repos/branch
- Conflict discovered in ' test.php '. //prompt conflict
- Select: (P) postpone, (DF) Diff-full, (e) Edit, //Here you choose how to handle
- (MC) Mine-conflict, (TC) Theirs-conflict,
- (s) Show All Options:p
- ---merging R7 through R12 into ' test.php ':
- C test.php
- Summary of conflicts:
- Text conflicts:1 //Although there is a conflict, but still can be synchronized, also indicates that the synchronization was successful.
- ---/tmp/tempfile.2.tmp Sun Oct 24 21:02:11 2010
- + + +. Svn/tmp/test.php.tmp Sun Oct 24 21:02:11 2010
- @@ -0,0 +1,9 @@
- +<<<<<<<. Working
- +asdfadfadfadf
- +111111111111111
- +=======
- +asdfadfadfadf
- +111111111111111
- +222222222222
- +
- +>>>>>>>. Merge-right.r12
1
Detailed description of SVN branch and merge---command line