Example Session: (Assumes that the repository has already been created. For Subversion repository creation and Subversion server configuration, see the (YoLinux Subversion and Trac tutorial) Checkout: svn checkout http://svnserver/repos/svn/trunk/Project1 Go to source code directory: cd Project1/src Edit files: vi file1.cpp vi file2.cpp Verify and test: make We are ready to check-in the files into the Subversion repository. Check repository and report on new revisions and changes others have checked in: svn status -u . After many long hours or days of editing and work, get updates others have made: svn update U file.h C file1.cpp G file2.cpp ? a.out You will see: U: File was updated with a newer version checked-in since your checkout. G: Automatically merged with no conflicts. C: Not merged due to conflicts. You made changes to the same section of code as the update made by someone else since your checkout. For each "conflicted" file there will be three new local files generated by "update": file1.cpp.mine (File - post editing) file1.cpp.rold (BASE - pre editing) file1.cpp.rnew (HEAD - Updated file from repository) The file file1.cpp still exists but with svn conflict marker strings added in the file. At this point, a check-in will fail until the merge is resolved. Merge options: Edit the file file1.cpp Text markers are placed in the file to show the conflicts between the "HEAD" and "mine" versions. OR tkdiff -conflict file1.cpp OR Use a GUI merge tool: kdiff3 file1.cpp.mine file1.cpp.rnew -o file1.cpp OR Throw out your changes/abort: svn revert file1.cpp No resolve or check-in necessary if file is reverted. Verify and test, again: make Notify Subversion that conflicts have been resolved: svn resolved file1.cpp Note: This also removes the temporary files ".mine" and ".r###". Check-in to Subversion repository: svn ci -m "Add comments here" file1.cpp Subversion Peg revisions: Peg revisions are used so Subversion can find a previous version of a resource (file or directory) if its' location was different than it is now. Peg revisions are that extra hint Subversion needs to clear up ambiguity. $ svn command -r OPERATIVE-REV item@PEG-REV The default peg revision is BASE for working copy items and HEAD for repository URLs. When no operative revision is provided, it defaults to being the same revision as the peg revision. The PEG-REV is specified if the resource (file/directory) in question use to appear in a directory which is no longer in the same place or no longer exists. The "peg-revision" must be specified so subversion can look at the directory in that revision so it can find the resource. If a peg revision is specified without an operative revision, then the operative revision is assumed to be the same as the peg revision. For more see: http://svnbook.red-bean.com/en/1.5/svn.advanced.pegrevs.html Subversion Properties: Files under revision control can include Subversion keywords which properties can be set with the "propset" command. Keywords are substituted with the Subversion properties and will not appear in the file until a commit is performed. Other properties are used to modify the behavior of Subversion. The following properties can be set on entities stored in Subversion: Property Description svn:ignore A newline separated list of file patterns to ignore. List of files/directories to be ignored by svn status svn:keywords Valid RCS style keywords are: HeadURL - The URL for the head version of the object. Also: $URL$ LastChangedBy - The last person to modify the file. Also: $Author$ LastChangedDate - The date/time the object was last modified. Will appear as: $LastChangedDate: 2005-07-22 22:02:37 -0700 (Fri, 22 Jul 2005) $ Also: $Date$ LastChangedRevision - Describes the last known revision. Will appear as: $LastChangedRevision: XXX $ where "XXX" is the revision number. Also: $Rev$, Revision $Id$ - A compressed summary of the previous 4 keywords. Example RCS style comment Example Output /* $URL$ $Rev$ $Author$ $Date$ $Id$ */ /* $URL:http://server/svn/path/file.cpp $ $ Rev:2 $ $ Author:Greg $ $ Date:2006-10-12 14:31:84 -0400 (Thu,12 Oct 2006)$ $ Id:file.cpp 3 2006-10-12 18:31:84Z Greg $ */ To turn on keyword processing for $URL$ and $Rev$ set the property svn:keywords and commit the file. The property is not assigned until a commit is performed. Subsequent check-outs and updates will have substitution performed on the working file: svn propset svn:keywords "URL Rev" source-file.cpp To turn this substitution off so that one can edit the original keywords. This also requires a check-in: svn propdel svn:keywords source-file.cpp svn:executable Ensure file attribute is executable. Possible values: ON, OFF Example: svn propset svn:executable ON app.exe svn:eol-style One of 'native', 'LF', 'CR', 'CRLF'. Specify and maintain specified line ending for text file. LF: Unix, Linux, standards based OS, proprietary legacy systems, etc. CRLF: DOS and Microsoft OSs CR: Response input scripts, etc Example: find ./ -name "*.h" -exec svn propset svn:eol-style LF {} \; svn:mime-type The mime type of the file: text/html text/css text/plain image/jpeg ... See file /etc/mime.types for a list of mime types. Examples: svn propset svn:mime-type text/plain file.cpp svn propset svn:mime-type text/html file.html Web pages rendered from subversion will display as HTML source rather than as a web page unless this mime type is applied. svn:needs-lock Prevents conflicts for files which can not be contextually merged. i.e. photos, binaries, object libraries. svn:externals List of files or directories pointed to. Locate repository where directory specified should be retrieved. The directive propset is not required: svn propedit svn:externals local-target-dir local-target-dir http://server/svn/dir-remote local-target-dir/subdir -r### http://server/svn/dir-remote2 svn update svn commit svn propget svn:externals ./ The property applies to the directory. Subversion can not list or web browse svn:externals. Check-out ("co"), "export" and "log" can be performed. Must set environment variable "EDITOR", "SVN_EDITOR", "VISUAL" or set the Subversion configuration file (~/.subversion/config) attribute editor-cmd. i.e.: export EDITOR=vi Note: Subversion 1.6 introduces file externals in addition to directory externals. The files however must reside in the same repository. Also, the file must point to a location which exists in your local working directory. [Potential Pitfall]: Apply svn externals to directories and not files. (version 1.4) [Potential Pitfall]: If generating a tag (branch), one should assign the revision number to the external link to truly snapshot the repository for that tag. This revision number should be specified in the tagged branch version of the svn external. [Potential Pitfall]: The revision numbers shown by svn info will reflect the version numbers of the repository in which the files are stored. If the files are imported via an svn external directory, the revision numbers will reflect that of the external repository which the external points to and thus from where the files were imported.