SVN Commands

SVN is a version tools for collaboration development. For Window, you can use TortoiseSVN with GUI interface. For Linux, it is more common to use commands. Below are some commonly used commands. The bold header are the actual command.

svn --help

Provide help access to all commands. For example, svn --help co will give you help on check out command

svn add file.txt or svn add dir

Add a file or the whole directory to the repository. Note that, adding is not equal to check in.

svn co URL folder

Checkout the file from repository from the given URL. To checkout, I recommend the following steps

1. Create a folder, ie, myFolder
2. Navigate to the folder
3 Type svn co http://your_svn_url .

This will help you check out the latest revision of your repository files into your current folder

If you want to checkout a certain revision of the file, use

svn co -r revisionNum http://your_svn_url

svn cleanup

It will help to cleanup your repository and release any holding lock

svn ci filename or svn ci dir

Commit the file into the repository. For example,

svn ci your_file
svn ci your_dir

If your server require username and password for checking in, you can use the following with a specific check in message

svn ci --username yourname --password yourpwd -m "your check in message" your_file_name

svn diff filename

It will show the different between your work copy against your repository copy

svn update

Update to the latest version in the repository. If filename or directory name given, it will only update the given filename or directory

svn delete filename or svn delete dir

Delete the give filename or directory in the repository

svn log filename or svn log dir

Show the log messages for the given file or directory input by the previous check in

svn info filename

Show the repository information about the file

svn status

Show the status of file changed in the current directory and sub-directory. It is useful to see what files are just added, changed or conflict.

svn switch

There are 2 usage of switch command

1. svn switch http://your_svn_url/newbranch
This will switch your current working copy to a new branch.

2. svn switch --relocate http://your_old_svn_url/trunk http://your_new_svn_url/trunk

This will relocate your current checkout url to the new url. Extremely useful if you are working in both extranet and intranet environment when your IP/domain name changes frequently

svn cp source destination

It is useful to create tag/branch in your repository. For example

svn cp http://your_svn_url/trunk http://your_svn_url/tags/your_tags_version

svn merge source destination

It is useful to merge your branch to trunk. Merging is the most headache of svn as it may create a lot of conflict. You can use the following to test merging

svn merge --dry-run http://your_svn_rul/branch http://your_svn_url/trunk

This will not perform merge, instead, it will tell you the svn feedback from svn such as file added, deleted or conflict

To perform real merge

svn merge http://your_svn_rul/branch http://your_svn_url/trunk

svn resolved filename

Tell svn that the given filename is resolved from conflict. Remember to commit the file after that.





Comments

Popular Posts