Wednesday, July 27, 2011

Basic SVN Commands

Here I'm gonna show you some basic SVN commands with some examples.

Checking out
svn co http://[hostname]/trunk

Checking in
svn ci

Viewing SVN information
This will display information, such SVN URL, revision number, etc.
svn info

Viewing SVN status
This will display information, such as files modified, added, deleted, etc.
svn status

Updating the local SVN repository
svn up

Viewing the diff
svn diff

Viewing SVN logs
svn log

Adding a file into SVN
svn add new_file.txt

Moving/Renaming a file from one place to another place
svn move old_file.txt new_file.txt

Deleting a file from SVN
svn del junk_file.txt

Reverting local changes in a file
svn revert whatever_file.txt

Reverting local changes recursively
svn revert -R *

Creating a branch/tag
svn copy http://[hostname]/trunk http://[hostname]/branches/1.0
svn copy http://[hostname]/trunk http://[hostname]/tags/1.0

De-commiting changes in the trunk
This will first do a diff between HEAD and rev 123 in the trunk and then do a dry-run before performing an actual merge.
svn diff -r HEAD:1234 http:/[hostname]/trunk
svn merge -r --dry-run HEAD:1234 http:/[hostname]/trunk
svn merge -r HEAD:1234 http:/[hostname]/trunk
svn ci

Merging changes from the branch to the trunk
Assume that the current directory is where the trunk code was checked out.
svn diff -r 1234:HEAD http://[hostname]branches/1.0
svn merge -r 1234:HEAD --dry-run http://[hostname]/branches/1.0
svn merge -r 1234:HEAD http://[hostname]/branches/1.0
svn ci

Merging changes from the trunk to the branch
Assume that the current directory is where the branch code was checked out.
svn diff -r 1234:HEAD http://[hostname]/trunk
svn merge -r 1234:HEAD --dry-run http://[hostname]/trunk
svn merge -r 1234:HEAD http://[hostname]/trunk
svn ci

Viewing SVN externals
svn propset svn:externals .

Editing SVN externals
svn propedit svn:externals .

Viewing who modified the file
svn blame whosefault.txt

No comments:

Post a Comment