wiki:pm-svn-cmds

Version 7 (modified by andreasw, 14 years ago) (diff)

corrected URL

Basic Subversion Commands

Below we list the subversion command line commands that a typical developer has to know about. Online help is available using svn help. A detailed description of each command can be found in the "Subversion Complete Reference" chapter of the subversion book, at http://svnbook.red-bean.com/nightly/en/svn.ref.html

svn help

Lists all available svn commands. Help for a specific command cmd can be obtained with svn help cmd.

svn checkout (short form: svn co)

Checks out a directory plus all subdirectories from a subversion repository. The COIN repositories are available from the URL https://projects.coin-or.org/svn. For each COIN package, say Pkg, you obtain everything in the package (including all branches and tags) by specifying "svn co https://projects.coin-or.org/svn/Pkg/"; if you only want a part of the code, such as the current official release (by convention in the subdirecory trunk, you type svn co https://projects.coin-or.org/svn/Pkg/trunk. Usually, you should specify the target directory where you want your local copy of the code to be stored (such as Coin-Pkg). If the target directory is omitted, the source code will be installed in a subdirectory with the name of the last directory in the URL, i.e., trunk in the example above.

If you want to specify a specific revision that you want to check out, you can do this using the -r N flag, where N is the revision number.

By default, svn checkout will download files from other subversion repositories, if svn externals are defined for directories in the specified URL, and will recurse to further locations if externals are defined there. If you don't want to download any externals, specify the --ignore-externals flag.

The COIN svn repository is set up in a way, so that everybody can download files, without having to provide a password. You will have to provide your id and password once, if you want to do a write action, such as svn submit.

svn update (short form: svn up)

Updates the local copy to the current version of the current directory and subdirectories, or of a specific directory, if this directory is given as argument (e.g., svn up subdir). If you have made changes in your local copy, subversion will try to merge the difference between the previously checked-out version and the new one. If it has trouble doing that, it will notify you of a conflict. You should then have a look at the files for which a conflict occured and fix it; the location of a conflict is marked by <<< and >>> strings. It is important that you resolve the conflict, either by using svn resolved or svn revert, because you will otherwise not be able to commit your changes.

The -r N flag allows you to update your local copy to a specific revision number (N). To avoid recursion into subdirectories during the update, use the -N flag. The --ignore-externals flags tells subversion to ignore the externals.

svn status (short form: svn st)

If you want to find out the status of the files in your local copy, you use this command. This will tell you, which files and directories in your local copy have local modifications, which files are marked for addition or deletion, etc. To see a list of the symbol that show up for the files, type "svn help status", or look read about it in the subversion book.

svn commit (short form: svn ci)

This command it used to commit your local modifications to the subversion repository. If add enter a file or directory name as argument, only the files or the directory (and everything below it) will be committed. If you omit this argument, the current directory and everything below it will be submitted. To suppress the recursion into subdirectories, you can specify the -N flag.

You should enter a message that describe the changes that you made, so that later on you can see in the subversion history what has been going on. You can enter the message on the command line, using the "-m" flag, followed by the message (in quotes). If you omit the -m flag, you default editor will open for you to enter the message.

Note: For most COIN packages, we use subversion externals to obtain dependencies. The commit command does not automatically recurse into externals; therefore, you have to do a commit by hand. Make sure you are not committing code to an external with a specified version number in the externals definition'''

svn diff (short form: svn di)

To see the details of local modifications in your working copy, you use this command. You can specify a file or directory name as argument, to narrow down, which modifications you want to have shown. Again, the -N flag can be used to suppress recursion into subdirectories. You can also see the differences of your local copy with respect to a particular revision in the repositry, by using the "-r N" flag, where N is the specific revision number.

svn revert

If you want to restore the current version in the repository and undo your local modifications, you use this command. By default, it reverts the modifications only made to a file or directory given to the command as argument; if the argument is omitted, only the current directory is reverted. If you want to revert more than just one file or directory, you can use the "-R" to enable the recursive action of the command.

svn resolved

This command is necessary to tell subversion that you resolved a conflict that occured earlier during an update or a merge. Unless you resolve those conflicts, you will not be able to commit local changes of the files and directories, for which the conflict occurred. A conflict is also resolve automatically, if you use the revert command.

svn add

You use this command to add new files and directories to the repository. You need to give subversion the name(s) of the file(s) or directory(ies) as argument. Note that the command acts recursively on directories, unless you use the "-N" flag. The file or directory must exist when you use this command. The file or directory will only be added to the repository when you do a svn commit.

svn remove (short form: svn rm)

This command deteles a file or directory (including content) in your local copy and marks those files for deletion. The files will be deleted in the repository when you type "svn commit" the next time. In your local copy, directories will actually remain there, until you commit, but they will be empty. Do not delete them by hand''. You should always use this command, and never the shell rm command directory on version controlled files and directories. Note that you can can give only one argument at a time to this command, i.e., in order to delete several files, you will have to use this command for each one, e.g., using the xargs UNIX command.

svn copy (short form: svn cp)

To copy a version controlled file in your local copy including its repository history, you use this command.

svn mkdir

This command creates a new version controlled subdirectory in your local copy. You can later add files in this new directory with svn add.

svn merge

This command is used to merge changes in a different part of the repository (like a branch) into the local copy. Please see the wiki page on branches to see how you can use it properly.

svn export

This command is essentially the same as svn checkout, except that it skips all subversion-internal stuff, and you won't be able to do any further revision management commands in the obtained directories. This command is used to extract files from the repository with the purpose of given the obtained files to someone else (e.g., in the form of a tarball).

Subversion Properties

To understand the next set of commands you need to know what Subversion Properties are. A subversion property is something associated with a file or a directory. In principle, you can pick any property name and any content. However, there are special subversion properties, that tell subversion some details about the file or directory.

  • svn:executable: If this property is set (with or without a value), subversion knows that this is an executable file, and will make it executable when you check it out. Note, when you want to mark a file as an executable file, you simply need to set this property for this file, and subversion will automatically make it executable in your local copy.
  • svn:eol-style: This property should be set to the value native for any text file. This way, it will be adapted correctly at a checkout to have the correct line-end bytes (which differ for example between UNIX and Windows systems).
  • svn:externals: This is a property that can be set for directories, and it defines subversion externals.
  • svn:mime-type: This property, set for a file, tells subversion the MIME type of the file.

It is a good idea to change your local subversion configuration to set those properties automatically for certain files, so that the properties are correctly set when you add a file. For this purpose, you should copy the following lines to the end of your $HOME/.subversion/config file:

[miscellany]
enable-auto-props = yes
[auto-props]
*.c        = svn:eol-style=native;svn:keywords="Author Date Id Revision"
*.cpp      = svn:eol-style=native;svn:keywords="Author Date Id Revision"
*.h        = svn:eol-style=native;svn:keywords="Author Date Id Revision"
*.hpp      = svn:eol-style=native;svn:keywords="Author Date Id Revision"
*.f        = svn:eol-style=native;svn:keywords="Author Date Id Revision"
*.F        = svn:eol-style=native;svn:keywords="Author Date Id Revision"
*.sh       = svn:eol-style=native;svn:executable
*.txt      = svn:eol-style=native
*.png      = svn:mime-type=image/png
*.jpg      = svn:mime-type=image/jpeg
*.JPG      = svn:mime-type=image/jpeg
*.jpeg     = svn:mime-type=image/jpeg
*.JPEG     = svn:mime-type=image/jpeg
*.gif      = svn:mime-type=image/gif
*.GIF      = svn:mime-type=image/gif
*.rtf      = svn:mime-type=application/rtf
*.RTF      = svn:mime-type=application/rtf
*.pdf      = svn:mime-type=application/pdf
*.PDF      = svn:mime-type=application/pdf
*.db       = svn:mime-type=application/octet-stream
*.ico      = svn:mime-type=application/octet-stream
*.mov      = svn:mime-type=video/quicktime
*.MOV      = svn:mime-type=video/quicktime
*.avi      = svn:mime-type=video/x-msvideo
*.AVI      = svn:mime-type=video/x-msvideo
*.mpg      = svn:mime-type=video/mpeg
*.MPG      = svn:mime-type=video/mpeg
*.mpeg     = svn:mime-type=video/mpeg
*.MPEG     = svn:mime-type=video/mpeg
*.mpe      = svn:mime-type=video/mpeg
*.MPE      = svn:mime-type=video/mpeg
*.zip      = svn:mime-type=application/zip
*.tgz      = svn:mime-type=application/x-gzip
*.gz       = svn:mime-type=application/x-gzip
*.doc      = svn:mime-type=application/msword
*.ppt      = svn:mime-type=application/vnd.ms-powerpoint
*.xls      = svn:mime-type=application/vnd.ms-excel
*.sxw      = svn:mime-type=application/vnd.sun.xml.
*.sxc      = svn:mime-type=application/vnd.sun.xml.writer
*.sxd      = svn:mime-type=application/vnd.sun.xml.calc
*.sxi      = svn:mime-type=application/vnd.sun.xml.impress
*.sxm      = svn:mime-type=application/vnd.sun.xml.math
*.mso      = svn:mime-type=application/octet-stream
*.wmf      = svn:mime-type=application/octet-stream
*.wmz      = svn:mime-type=application/x-gzip
*.prz      = svn:mime-type=application/octet-stream
Makefile   = svn:eol-style=native;svn:keywords="Author Date Id Revision"
Makefile.ac = svn:eol-style=native;svn:keywords="Author Date Id Revision"
configure.ac = svn:eol-style=native;svn:keywords="Author Date Id Revision"

svn proplist (short form: svn plist)

This command takes as argument the name of a file or directory, and lists all properties given to this file or directory. By default, you only see the names of the properties, without their values. If you want to see also their values, use the "-v" flag.

svn propget (short form: svn pget)

This command tells you the value for a specific property for a file or directory. As first argument, you need to specify the name of the property (e.g., svn:externals), and as second argument the name of the file or directory.

svn propset (short form: svn pset)

With this command you can set the value of a specify property for a file or directory. As the first argument, you need to specify the name of the property, then the value of the property (use quotation if this has more than one word), and finally you need to specify the name of the file or directory. You can also provide the value as the content of a file, say FileName, in which case you omit the value argument, and use the "-F FileName" flag instead. In COIN, we use this to assign subversion externals.

svn propdel (short form: svn pdel)

Finally, you can delete a specific property of a file or directory. As first argument, you specify the name of the property, and then the name of the file or directory.