As most of used SVN on windows we would know mergeing, Branching etc on windows with the help of graphical user interface. But sometimes we also need to work on UNIX/LINUX environment and in that case if we want to use SVN we would need to know the commands to create branch, merge branch, check in, check out etc. In this post let me show some of commands used for creating branch, merging branch into trunk, updating branch.
1. Merge a Branch into Trunk
a. Check out the trunk:
svn co svn+ssh://server/path/to/trunk
b. Check out a copy of the branch you are going to merge:
svn co svn+ssh://server/path/to/branch/myBranch
c. Change your current working directory to “myBranch” .Find the revision “myBranch” began at:
svn log --stop-on-copy
This should display back to you the changes that have been made back to the point the branch was cut. Remember that number (should be rXXXX, where XXXX is the revision number).
d. Change your current working directory to trunk # Perform an SVN update:
svn up
This will update your copy of trunk to the most recent version, and tell you the revision you are at. Make note of that number as well (should say “At revision YYYY” where YYYY is the second number you need to remember).
e. Now we can perform an SVN merge:
svn merge -rXXXX:YYYY svn+ssh://server/path/to/branch/myBranch
This will put all updates into your current working directory for trunk.
f. Resolve any conflicts that arose during the merge and Check in the results:
svn ci -m "MERGE myProject myBranch [XXXX]:[YYYY] into trunk"
That is it. You have now merged “myBranch” with trunk.
2. Branch Creation
a. Get the head revision
svn info svn://server.com/svn/repository/trunk | grep Revision
b. Create a branch
svn cp svn://server.com/svn/repository/trunk \ svn://server.com/svn/repository/branches/your_branch \ -m "Branching from trunk to your_branch at HEAD_REVISION"
c. Swtich to new branch
svn switch --relocate \ svn://server.com/svn/repository/trunk \ svn://server.com/svn/repository/branches/your_branch
d. Update you current directory
svn info | grep URL svn up
e. commit your new changes
3. Updating the branch
a. Update your current branch
b. Search the subversion logs to check what revision number last merged.
svn log --limit 500 | grep -B 3 your_branch
c.Get the head revision
svn info svn://server.com/svn/repository/trunk | grep Revision
d. Merge the difference of the last merged revision on trunk and the head revision on trunk into the your branch working copy
svn merge -r LAST_MERGED_REVISION:HEAD_REVISION \ svn://server.com/svn/repository/trunk .
Replace LAST_MERGED_REVISION with the revision number you noted in step 2, and HEAD_REVISION with the revision number you noted in step 3.
Now look for errors in the output. Could all files be found? Did things get deleted that shouldn’t have been? Maybe you did it wrong. If you need to revert, run svn revert -R *.
e. Check for conflicts.
svn status | egrep '^C|^.C'
Resolve any conflicts. Make sure the application starts and the tests pass.
f. Commit merge changes.
svn ci -m "Merged changes from trunk to your_branch"
No comments:
Post a Comment