Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Version 7 (modified by nicolasc, 17 years ago) (diff)

SVN

This Page contains a collection of the most used svn command including some examples. This page does not claim to be complete. for further reading use the built-in help function from svn. the syntax is svn help <command>, of command is omitted, a complete list of valid svn command in printed to the comsole. Further it is assumed that the user has a basic understanding of the shell, and know he way around in the file structure. svn allow most flexibilities the bash shell allows.

these are some examples, which are elaborated further down.

svn co https://svn.orxonox.net/data/trunk data
svn up
svn ci -m "some message"
svn add myFile.cc myFile.h
svn rm trash-folder
svn mv myFile.cc myFile.h myFolder
svn cp https://svn.orxonox.net/orxonox/trunk https://svn.orxonox.net/orxonox/branches/test
svn resolved somefile.cc
svn revert 
svn diff

If not noted otherwise all commands are recursive.

checkout (co)

the checkout command is used to create a local copy of a svn subtree on the local computer.

the syntax used is svn co -r <revision> <remote-path> <local-path>, if -r <revision> is omitted, the HEAD revision is assumed, which is also the newest one, if <local-path> is omitted the last remote folder will be used as <local-path>.

This will create a folder orxonox-trunk with the contents of the trunk

svn co https://svn.orxonox.net/orxonox/trunk orxonox-trunk

This will create a folder called test, with the content of the test branch at revision 200.

svn co -r 200 https://svn.orxonox.net/orxonox/branches/test

update (up)

update is closely related to checkout, as it also download - or updates - the svn tree. while checkout is normally only used once, update is used all the time. the syntax is svn up <local-path>, if <local-path> is omitted the current update will be allied to the current directory.

This will update the current folder including subfolders.

svn up

This will update the trunk and the test-branch.

svn up trunk branches/test

Updates may cause conflicts if the remote and local file has been changed in the same place. to resolve a conflict see here.

commit (ci)

sometime also called checkin, does the opposite of checkout or update, it upload changes made to the local the to the server. The syntax is svn ci -m <commit message> <local-path>, if <local-path> is omitted, the current directory is assumed, if -m <commit message> is ommited, an editor will pop up where you can (and should) write a meaningful commit message.

this will checkin the current directory including subfolders with the comment "initial upload"

svn ci -m "initial upload"

A commit is only possible if the local version is up-to-date. if it isn't you will get an error, and the commit will fail. the solution then is to do an update.

add

adding a new file to the local svn copy, that it get upload with the next commit. the syntax is svn add <file>

this will add the files myFile.cc and myFile.h in the folder myFolder to the svn

svn add myFolder/myFile.cc myFolder/myFile.h

remove (rm)

also called delete, which deletes an item from the svn tree. please note that this also removed the file/folder from the local harddrive. the syntax is svn rm <file/folder>. you still need to commit it to the server.

this will remove the file myOldFile.cc from the svn tree

svn rm myOldFile.cc

move (mv)

sometime called rename (ren) - as a rename is the same as a move. The command simplifies the rearranging of files in the svn tree. the syntax is svn mv <source files> <target-folder>

this will move the files myFile.cc and myFile.h to myFolder

svn mv myFile.cc myFile.h myFolder

this will rename the file myFiel.cc to myFile.cc - to correct a typo. please note the mv and rename are the same command

svn ren myFiel.cc myfile.cc

copy (cp)

a command which is rarely used on the local tree - why would someone need a file twice in the same tree? - but it is rather useful to create new branches. though it is normally done by the supervisors, it can be done by the students.

this will create a new branch called test from the current version of the trunk

svn cp https://svn.orxonox.net/orxonox/trunk https://svn.orxonox.net/orxonox/branches/test

resolved

if a conflict arises - this normally happens if someone change a file on the server (committed it) while you were doing changes in the same place. This command does not solve the conflict, but it removes the other unnecessary files.

this will resolve the conflict in in myConflictFile.cc, and make the copy committable again.

svn resolved myConflictFile.cc

revert

One of the major advantages of a version control system, is that you can always revert to a known saved state - in this case the last updated local revision. revert removes all local changes and restores the file to a state prior editing, i.e discarding all local changes.

this will discard all local changes made to myFile.cc

svn revert myFile.cc

diff (di)

another rarely used but very useful command. it shows you the difference between the downloaded revision and the current state, which basically what will be uploaded at the next commit. It is also useful to check if all new files have been added to the svn tree - it happens very often, the there are two commits in short time, first the updates, then the new files. the syntax is svn di <local-path>, if <local-path> is omitted, the current directory is assumed.

this will show - print to the console - the current changes made to the revision

svn di .