2013年8月28日星期三

SVN in the creation and consolidation Branch

 
  
   
    

    

in the use of source code version control tool, the best practice is to remain a trunk version. But in order to cope with the actual development of the various situations, timely introduction of some branches is also necessary. For example, in the same time continuing to develop new features, you need to release a new version, then you need to create a trunk from the development branch for publishing, on a branch for bug fix, maintain a stable version, and some changes will be timely merged back trunk. Currently ubiquitous source code version control tool git popular with everyone respected, one of the reasons is its function in this regard is quite powerful. In fact, there is such a veteran of SVN is a function, then gave you on the next.

         

Branch was created

    

in SVN trunk code is generally placed in the Trunk directory, so if you want the new Branch is placed in Branchs directory. (Note that this is a convention, SVN does not force you to do so) Note Branhs Trunk directories should be flat and level, there can be nested, to not cause confusion.

    
     
            
     
                                                                   
1 
2
3
4
  myproject/ 
trunk/
branches/
tags/
     
    
    Creating a Branch

quite simple, just a command.

    
     
            
     
                                                                   
1 
svn copy http://example.com/repos/myproject/trunk http://example.com/repos/myproject/branches/releaseForAug -m 'create branch for release on August' 
     
    
    

This command is to create a directory named myproject releaseForAug this repo's branch, use the-m to add descriptions.

    

then you can pass svn checkout http://example.com/repos/myproject/branches/releaseForAug to move out of your Branch source files, the above modifications and submitted.

    In fact, no Branch SVN

internal concept. We just created a repo copy, and giving yourself a copy as a Branch of the significance of this, so this is the git Branch are very different.

    

Note that Branch and Trunk version using the same set, ie both in the Branch or Trunk submission will cause major version number increases. This is because svn copy supports only within the same repository file copy, does not support cross-repository of copy, so the newly created Branch and Trunk belong to the same repository.

    

merge

    Since

also need to create a branch merge branch. Basic combination is also quite simple.

    Suppose now that Branch

fix on a series of bug, now we want to change for the Branch synchronized to the Trunk, then how should I do that?

    
         
  1. ensure that the current Branch branch is clean, that is to use svn status can not see any local modifications.

  2.      
  3. command line switch to the Trunk directory, use svn merge http://example.com/repos/myproject/branches/releaseForAug to the Branch branch changes to merge back Trunk next.

  4.      
  5. If merge is to resolve the conflict, and then perform svn ci-m 'description' to submit the change.

  6.     
    

course, you can also specify the Branch merge those on version changes can be merged into Trunk.

    
     
            
     
                                                                   
1 
svn merge  http://example.com/repos/myproject/branches/releaseForAug -r150:HEAD 
     
    
    

example is the Branch from version 150 to the current version of all the changes are merged into the Trunk.

    

you can also Trunk some of the updates into the Branch, or whether the same method.

    View the current Branch and Trunk

merger case

    

can use svn mergeinfo to view the merge situation.

    View the current Branch

those changes have already been merged into Trunk.:

    
     
            
     
                                                                   
1 
2
# cd to trunk directory 
svn mergeinfo http://example.com/repos/myproject/branches/releaseForAug
     
    
    

View Branch merge those changes yet.

    
     
            
     
                                                                   
1 
2
3
#cd to trunk directory 

svn merginfo http://example.com/repos/myproject/branches/releaseForAug --show-revs eligible
     
    
   
  
 

没有评论:

发表评论