Summary:
1. after the trunk establishes a branch, it simultaneously modifies a class file with the branch. the merge steps are as follows: trunk> trunk. Some people may think that trunk> trunk can be used as the trunk. generally, all online services are trunk. instead of a branch, the slave branch-> the trunk. If the master branch is finished, merge should have no obstacles.
2. The branch log contains the logs before the trunk is split into a branch. You can also use the command to display the branch log only after splitting.
3. When a conflict occurs, the diff version is used for display. You can directly edit the conflict file to eliminate the conflict.
4. the version number is calculated for the entire project. The project includes trunk, branch, and tag.
-------------------------------------------------------------------------------
From http://blog.csdn.net/jixiuffff/archive/2010/05/13/5586858.aspx
Suppose the trunk is like this.
A ----> B ------> C -----> D ------------> E
A B C D E represents the version numbers respectively.
It suddenly found that the project introduced a bug in version E. It may take some time to modify the bug.
That is, if the code is directly modified at E, it may affect others to continue development. One way is to copy e code to another place (create a branch)
, Fix the bug on this branch. After the bug is fixed, merge it into the trunk to continue development.
A ----> B ------> C -----> D ------------> E --------> F ------------> G (continue normal development of the trunk)
|
| Create a branch
V
E1 --------> F1 --------> G1
When the branch reaches G1, the bug is corrected. In this case, merge the branch (merge) into the trunk and change it to the following State:
A ----> B ------> C -----> D ------------> E --------> F
------------> G -------> H -------->
| ^
| Create a branch |
V |
E1 --------> F1 ---------> G1 --------->
Merge the Code G and G1 (conflicts may need to be resolved before merging) into H and continue development.
The Demo code is as follows:
: Assume that all projects are stored in SVN: // localhost/Java.
Create a DRP project SVN: // localhost/Java/DRP
1. Create a project locally
Jixiuf @ JF/tmp/svntmp $ mkdir DRP/{trunk, branches, tag}
Create directory
Jixiuf @ JF/tmp/svntmp $ touch
DRP/trunk/{hello. Java, hello2.java, hello3.java}
Create several files
Jixiuf @ JF/tmp/svntmp $ tree directory structure:
Jixiuf @ JF/tmp/svntmp $ tree
.
── DRP
── Branches
── Tag
── Trunk
── Hello2.java
── Hello3.java
── Hello. Java
4 directories, 3 files
Trunk: The main directory of the Project. branches is the branch directory,
Submit the project to SVN: // localhost/Java/DRP, that is, create the svn: // localhost/Java/DRP project.
Jixiuf @ JF/tmp/svntmp $
SVN
Import-M "create the project DRP" DRP/SVN: // localhost/Java/DRP
Delete the DRP directory of the local database, and then download it remotely.
Jixiuf @ JF/tmp/svntmp $ rm drp/-RF
Jixiuf @ JF/tmp/svntmp $ SVN Co SVN: // localhost/Java/DRP
Jixiuf @ JF
/Tmp/svntmp $ CD DRP
Jixiuf @ JF/tmp/svntmp/DRP $
SVN log: Check the log and create the project DRP in version 84.
------------------------------------------------------------------------
R84 | jixiuf | 14:44:21 + 0800 (4, 2010-05-13) | 1 line
Create the project DRP ------------------------------ this is run
SVN
Log information added when import-M "create the project DRP" DRP/SVN: // localhost/Java/DRP
------------------------------------------------------------------------
At this time, r84 is the E State mentioned above (a bug was found and a branch was decided to be created to solve the bug)
Jixiuf @ JF/tmp/svntmp/DRP $ svn cp-M "Create a branch" SVN: // localhost/Java/DRP/trunk/SVN: // localhost/Java/DRP/branches/debugdrp1.0
The submitted version is 85.
Create a branch and name it debugdrp1.0
Because the local DRP version is r84 and the server version is r85, you need to update it.
Jixiuf @ JF/tmp/svntmp/DRP $ SVN up is short for update (the same is true for SVN update commands)
Jixiuf @ JF/tmp/svntmp/DRP $ tree now let's take a look at the directory structure (we will find that there are multiple debugdrp1.0 directories under the branches directory, and the files in the directory are the files in the trunk directory. This process is called creating a branch)
.
── Branches
│ ── Debugdrp1.0
│ ── Hello2.java
│ ── Hello3.java
│ ── Hello. Java
── Tag
── Trunk
── Hello2.java
── Hello3.java
── Hello. Java
4 directories, 6 files
Jixiuf @ JF/tmp/svntmp/DRP $ SVN log
Take a look at the log records
------------------------------------------------------------------------
R85 | jixiuf | 14:51:35 + 0800 (4, 2010-05-13) | 2 rows
Create a branch
------------------------------------------------------------------------
R84 | jixiuf | 14:44:21 + 0800 (4, 2010-05-13) | 1 line
Create the project DRP
------------------------------------------------------------------------
Assume that the bug file is hello. java.
Modify hello. Java in the branches/debugdrp1.0 directory
In this case, the bug is modified.
Jixiuf @ JF/tmp/svntmp/DRP $ echo "bug fixed"> branches/debugdrp1.0/Hello. Java
Is added to the end of the file hello. Java
The bug has been fixed.
To show that, if the dash is cleared, add some information to hello. Java in the trunk to create a conflict.
Jixiuf @ JF/tmp/svntmp/DRP $ echo "information added to hello. Java in the trunk to generate a conflict"> trunk/Hello. Java
Submit to server now
Jixiuf @ JF/tmp/svntmp/DRP $ SVN ci-M "Modify the hello. Java in branches/debugdrp1.0 and trunk"
Sending branches/debugdrp1.0/Hello. Java
Sending trunk/Hello. Java
Transfer file data ..
The submitted version is 86.
Jixiuf @ JF/tmp/svntmp/DRP $ SVN up
Update to the latest version 86.
Now the bug is in
Branches/debugdrp1.0 was corrected, and the file hello. Java was modified in the trunk during this process,
People who fixed the bug found that some new changes have already been made in the trunk and need to add these new changes,
That is, merge the things in the trunk into the branch.
Come,
========================================================== ==================================
Jixiuf @ JF/tmp/svntmp/DRP $ CD branches/debugdrp1.0/
To the root directory of the debugdrp1.0 Branch
Then take a look at the log
Jixiuf @ JF/tmp/svntmp/DRP/branches/debugdrp1.0 $
SVN log
View All logs. (Note that the branch logs include the trunk logs before the branch is created, and the independent logs developed on the branch after the branch is created. Now, view all directories.
)
------------------------------------------------------------------------
R86 | jixiuf | 15:13:23 + 0800 (4, 2010-05-13) | 1 line
Modify the hello. Java in branches/debugdrp1.0 and trunk
------------------------------------------------------------------------
R85 | jixiuf | 14:51:35 + 0800 (4, 2010-05-13) | 2 rows
Create a branch
------------------------------------------------------------------------
R84 | jixiuf | 14:44:21 + 0800 (4, 2010-05-13) | 1 line
Create the project DRP
------------------------------------------------------------------------
Jixiuf @ JF/tmp/svntmp/DRP/branches/debugdrp1.0 $
SVN log -- stop-on-copy
(View the independent development logs on the branch after the branch is created, excluding the logs on the trunk)
------------------------------------------------------------------------
R86 | jixiuf | 15:13:23 + 0800 (4, 2010-05-13) | 1 line
Modify the hello. Java in branches/debugdrp1.0 and trunk
------------------------------------------------------------------------
R85 | jixiuf | 14:51:35 + 0800 (4, 2010-05-13) | 2 rows
Create a branch
------------------------------------------------------------------------
Jixiuf @ JF/tmp/svntmp/DRP/branches/debugdrp1.0 $ SVN merge SVN: // localhost/Java/DRP/trunk
Merge the trunk Directory into the current directory
Conflicts are found in "Hello. Java.
Select: (p) postponed, (DF) show all differences, (e) edit,
(MC) My version, (TC) others' version,
(S) show all options:
As a result, the following message is displayed, indicating that hello. Java has a conflict, and then it provides several solutions,
P deferred (multiple helllo. java files will be generated in the same directory of Hello. Java, with r84
Version, which is the version before the conflict, as well as the version on the branch, the version on the trunk, and a version generated after the diff comparison) needs to be manually modified hello. Java
Delete other versions, and then submit the svn CI.
DF only displays differences between files. e edits files to resolve conflicts directly.
Select E
An editor is displayed, with the following content:
<. Working
Bug fixed
========
Information added to hello. Java in the trunk to generate conflicts
>>>>>>>. Merge-right.r86
~
~
This indicates that hello. Java has the "bug fixed" line in the directory of the current job (. Working ).
. Merge-right.r86 file (that is, there is this line in hello. Java in the trunk) "information added to hello. Java in the trunk for conflict"
Merge files
Bug fixed
Information added to hello. Java in the trunk to generate conflicts
Select R after resolving the conflict
Then, the trunk is merged to the current branch to view
Jixiuf @ JF/tmp/svntmp/DRP/branches/debugdrp1.0 $ cat hello. Java
Bug fixed
Information added to hello. Java in the trunk to generate conflicts
========================================================== ================
In addition, although the Code in the branch has fixed the bug and has the latest code added to the trunk
And merge it into trunk.
Jixiuf @ JF/tmp/svntmp/DRP/branches/debugdrp1.0 $ CD/tmp/svntmp/DRP/trunk/
Jixiuf @ JF/tmp/svntmp/DRP/trunk $ SVN merge SVN: // localhost/Java/DRP/branches/debugdrp1.0
Similarly, after resolving the conflict, you can continue code development in trunk.
A ----> B ------> C -----> D ------------> E --------> F
------------> G -------> H -------->
| ^
| Create a branch |
V |
E1 --------> F1 ---------> G1 --------->