To use the command line client, you type svn, the subcommand you wish to use,[1] and any switches or targets that you wish to operate on there is no specific order that the subcommand and the switches must appear in. For example, all of the following are valid ways to use svn status:
$ svn -v status $ svn status -v $ svn status -v myfile You can find many more examples of how to use most client commands in Chapter 3 and commands for managing properties in Section 7.2. 9.1.1 svn SwitchesWhile Subversion has different switches for its subcommands, all switches are global that is, each switch is guaranteed to mean the same thing regardless of the subcommand you use it with. For example, --verbose (-v) always means verbose output, regardless of the subcommand with which you use it.
9.1.2 svn Subcommands
Synopsissvn add PATH... DescriptionAdds files and directories to your working copy and schedules them for addition to the repository. They will be uploaded and added to the repository on your next commit. If you add something and change your mind before committing, you can unschedule the addition using svn revert. Alternate NamesNone ChangesWorking copy Switches--targets FILENAME --non-recursive (-N) --quiet (-q) --config-dir DIR --auto-props --no-auto-props ExamplesTo add a file to your working copy: $ svn add foo.c A foo.c When adding a directory, the default behavior of svn add is to recurse: $ svn add testdir A testdir A testdir/a A testdir/b A testdir/c A testdir/d You can add a directory without adding its contents: $ svn add --non-recursive otherdir A otherdir
Synopsissvn blame TARGET... DescriptionShows author and revision information in-line for the specified files or URLs. Each line of text is annotated at the beginning with the author (username) and the revision number for the last change to that line. Alternate Namespraise, annotate, ann ChangesNothing Accesses RepositoryYes Switches--revision (-r) REV --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesIf you want to see blame-annotated source for readme.txt in your test repository: $ svn blame http://svn.red-bean.com/repos/test/readme.txt 3 sally This is a README file. 5 harry You should read this.
Synopsissvn cat TARGET... DescriptionOutputs the contents of the specified files or URLs. For listing the contents of directories, see svn list. Alternate NamesNone ChangesNothing Accesses RepositoryYes Switches--revision (-r) REV --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesIf you want to view readme.txt in your repository without checking it out: $ svn cat http://svn.red-bean.com/repos/test/readme.txt This is a README file. You should read this. If your working copy is out of date (or you have local modifications) and you want to see the HEAD revision of a file in your working copy, svn cat will automatically fetch the HEAD revision when you give it a path: $ cat foo.c This file is in my local working copy and has changes that I've made. $ svn cat foo.c Latest revision fresh from the repository!
Synopsissvn checkout URL... [PATH] DescriptionChecks out a working copy from a repository. If PATH is omitted, the basename of the URL will be used as the destination. If multiple URLs are given each is checked out into a subdirectory of PATH, with the name of the subdirectory being the basename of the URL. Alternate Namesco ChangesCreates a working copy. Accesses RepositoryYes Switches--revision (-r) REV --quiet (-q) --non-recursive (-N) --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesCheck out a working copy into a directory called mine: $ svn checkout file:///tmp/repos/test mine A mine/a A mine/b Checked out revision 2. $ ls mine Check out two different directories into two separate working copies: $ svn checkout file:///tmp/repos/test file:///tmp/repos/quiz A test/a A test/b Checked out revision 2. A quiz/l A quiz/m Checked out revision 2. $ ls quiz test Check out two different directories into two separate working copies, but place both into a directory called working-copies: $ svn checkout file:///tmp/repos/test file:///tmp/repos/quiz working-copies A working-copies/test/a A working-copies/test/b Checked out revision 2. A working-copies/quiz/l A working-copies/quiz/m Checked out revision 2. $ ls working-copies If you interrupt a checkout (or something else interrupts your checkout, such as loss of connectivity, etc.), you can restart it either by issuing the identical checkout command again, or by updating the incomplete working copy: $ svn checkout file:///tmp/repos/test test A test/a A test/b ^C svn: The operation was interrupted svn: caught SIGINT $ svn checkout file:///tmp/repos/test test A test/c A test/d ^C svn: The operation was interrupted svn: caught SIGINT $ cd test $ svn update A test/e A test/f Updated to revision 3.
Synopsissvn cleanup [PATH...] DescriptionRecursively cleans up the working copy, removing locks and resuming unfinished operations. If you ever get a working copy locked error, run this command to remove stale locks and get your working copy into a usable state again. See Appendix B. If, for some reason, an svn update fails due to a problem running an external diff program (e.g., user input or network failure), pass the --diff3-cmd to allow cleanup to complete any merging with your external diff program. You can also specify any configuration directory with the --config-dir switch, but you should need these switches extremely infrequently. Alternate NamesNone ChangesWorking copy Accesses RepositoryNo Switches--diff3-cmd CMD --config-dir DIR ExamplesWell, there's not much to the examples here, as svn cleanup generates no output. If you pass no PATH, . is used: $ svn cleanup $ svn cleanup /path/to/working-copy
Synopsissvn commit [PATH...] DescriptionSends changes from your working copy to the repository. If you do not supply a log message with your commit by using either the --file or --message switch, svn will launch your editor for you to compose a commit message. See editor-cmd in Section 7.1.3.2.
Alternate Namesci (short for "check in," not co, which is short for "check out") ChangesWorking copy, repository Accesses RepositoryYes Switches--message (-m) TEXT --file (-F) FILE --quiet (-q) --non-recursive (-N) --targets FILENAME --force-log --username USER --password PASS --no-auth-cache --non-interactive --encoding ENC --config-dir DIR ExamplesCommit a simple modification to a file with the commit message on the command line and an implicit target of your current directory (.): $ svn commit -m "added howto section." Sending a Transmitting file data . Committed revision 3. Commit a modification to the file foo.c (explicitly specified on the command line) with the commit message in a file named msg: $ svn commit -F msg foo.c Sending foo.c Transmitting file data . Committed revision 5. If you want to use a file that's under version control for your commit message with --file, you need to pass the --force-log switch: $ svn commit --file file_under_vc.txt foo.c svn: The log message file is under version control svn: Log message file is a versioned file; use '--force-log' to override $ svn commit --force-log --file file_under_vc.txt foo.c Sending foo.c Transmitting file data . Committed revision 6. To commit a file scheduled for deletion: $ svn commit -m "removed file 'c'." Deleting c Committed revision 7.
Synopsissvn copy SRC DST DescriptionCopies a file in a working copy or in the repository. SRC and DST can each be either a working copy (WC) path or URL:
You can only copy files within a single repository. Subversion does not support cross-repository copying. Alternate Namescp ChangesRepository if destination is a URL. Working copy if destination is a WC path. Accesses RepositoryIf source or destination is in the repository, or if needed to look up the source revision number. Switches--message (-m) TEXT --file (-F) FILE --revision (-r) REV --quiet (-q) --username USER --password PASS --no-auth-cache --non-interactive --force-log --editor-cmd EDITOR --encoding ENC --config-dir DIR ExamplesCopy an item within your working copy (only schedules the copy nothing goes into the repository until you commit): $ svn copy foo.txt bar.txt A bar.txt $ svn status A + bar.txt Copy an item in your working copy to a URL in the repository (an immediate commit, so you must supply a commit message): $ svn copy near.txt file:///tmp/repos/test/far-away.txt -m "Remote copy." Committed revision 8. Copy an item from the repository to your working copy (only schedules the copy nothing goes into the repository until you commit): This is the recommended way to resurrect a dead file in your repository! $ svn copy file:///tmp/repos/test/far-away near-here A near-here And finally, copying between two URLs: $ svn copy file:///tmp/repos/test/far-away file:///tmp/repos/test/over-there -m "remote copy." Committed revision 9. This is the easiest way to tag a revision in your repository just svn copy that revision (usually HEAD) into your tags directory. $ svn copy file:///tmp/repos/test/trunk file:///tmp/repos/test/tags/0.6.32-prerelease -m "tag tree" Committed revision 12. And don't worry if you forgot to tag you can always specify an older revision and tag anytime: $ svn copy -r 11 file:///tmp/repos/test/trunk file:///tmp/repos/test/tags/0.6.32- prerelease -m "Forgot to tag at rev 11" Committed revision 13.
Synopsissvn delete PATH... svn delete URL... DescriptionItems specified by PATH are scheduled for deletion upon the next commit. Files (and directories that have not been committed) are immediately removed from the working copy. The command will not remove any unversioned or modified items; use the --force switch to override this behavior. Items specified by URL are deleted from the repository via an immediate commit. Multiple URLs are committed atomically. Alternate Namesdel, remove, rm ChangesWorking copy if operating on files, repository if operating on URLs Accesses RepositoryOnly if operating on URLs Switches--force --force-log --message (-m) TEXT --file (-F) FILE --quiet (-q) --targets FILENAME --username USER --password PASS --no-auth-cache --non-interactive --editor-cmd EDITOR --encoding ENC --config-dir DIR ExamplesUsing svn to delete a file from your working copy merely schedules it to be deleted. When you commit, the file is deleted in the repository: $ svn delete myfile D myfile $ svn commit -m "Deleted file 'myfile'." Deleting myfile Transmitting file data . Committed revision 14. Deleting a URL, however, is immediate, so you have to supply a log message: $ svn delete -m "Deleting file 'yourfile'" file:///tmp/repos/test/yourfile Committed revision 15. Here's an example of how to force deletion of a file that has local mods: $ svn delete over-there svn: Attempting restricted operation for modified resource svn: Use --force to override this restriction svn: 'over-there' has local modifications $ svn delete --force over-there D over-there
Synopsissvn diff [-r N[:M]] [--old OLD-TGT] [--new NEW-TGT] [PATH...] svn diff -r N:M URL svn diff [-r N[:M]] URL1[@N] URL2[@M] DescriptionDisplays the differences between two paths. The three different ways you can use svn diff are as follows: svn diff [-r N[:M]] [--old OLD-TGT] [--new NEW-TGT] [PATH...] displays the differences between OLD-TGT and NEW-TGT. If PATHs are given, they are treated as relative to OLD-TGT and NEW-TGT and the output is restricted to differences in only those paths. OLD-TGT and NEW-TGT may be working copy paths or URL[@REV]. OLD-TGT defaults to the current working directory and NEW-TGT defaults to OLD-TGT. N defaults to BASE or, if OLD-TGT is a URL, to HEAD. M defaults to the current working version or, if NEW-TGT is a URL, to HEAD. svn diff -r N sets the revision of OLD-TGT to N, svn diff -r N:M also sets the revision of NEW-TGT to M. svn diff -r N:M URL is shorthand for svn diff -r N:M --old=URL --new=URL. svn diff [-r N[:M]] URL1[@N] URL2[@M] is shorthand for svn diff [-r N[:M]] --old=URL1 -- new=URL2. If TARGET is a URL, then revs N and M can be given either via the --revision or by using @ notation as described earlier. If TARGET is a working copy path, then the --revision switch means:
If the alternate syntax is used, the server compares URL1 and URL2 at revisions N and M respectively. If either N or M are omitted, a value of HEAD is assumed. By default, svn diff ignores the ancestry of files and merely compares the contents of the two files being compared. If you use --notice-ancestry, the ancestry of the paths in question will be taken into consideration when comparing revisions (that is, if you run svn diff on two files with identical contents but different ancestry you will see the entire contents of the file as having been removed and added again). Alternate Namesdi ChangesNothing Accesses RepositoryFor obtaining differences against anything but BASE revision in your working copy Switches--revision (-r) REV --old OLD-TARGET --new NEW-TARGET --extensions (-x) "ARGS" --non-recursive (-N) --diff-cmd CMD --notice-ancestry --username USER --password PASS --no-auth-cache --non-interactive --no-diff-deleted --config-dir DIR ExamplesCompare BASE and your working copy (one of the most popular uses of svn diff): $ svn diff COMMITTERS Index: COMMITTERS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --- COMMITTERS (revision 4404) +++ COMMITTERS (working copy) See how your working copy's modifications compare against an older revision: $ svn diff -r 3900 COMMITTERS Index: COMMITTERS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --- COMMITTERS (revision 3900) +++ COMMITTERS (working copy) Compare revision 3000 to revision 3500 using @ syntax: $ svn diff http://svn.collab.net/repos/svn/trunk/COMMITTERS@3000 http://svn.collab. net/repos/svn/trunk/COMMITTERS@3500 Index: COMMITTERS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --- COMMITTERS (revision 3000) +++ COMMITTERS (revision 3500) ... Compare revision 3000 to revision 3500 using range notation (you only pass the one URL in this case): $ svn diff -r 3000:3500 http://svn.collab.net/repos/svn/trunk/COMMITTERS Index: COMMITTERS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --- COMMITTERS (revision 3000) +++ COMMITTERS (revision 3500) Compare revision 3000 to revision 3500 of all files in trunk using range notation: $ svn diff -r 3000:3500 http://svn.collab.net/repos/svn/trunk Compare revision 3000 to revision 3500 of only three files in trunk using range notation: $ svn diff -r 3000:3500 --old http://svn.collab.net/repos/svn/trunk COMMITTERS README HACKING If you have a working copy, you can obtain the differences without typing in the long URLs: $ svn diff -r 3000:3500 COMMITTERS Index: COMMITTERS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = --- COMMITTERS (revision 3000) +++ COMMITTERS (revision 3500) Use --diff-cmd CMD -x to pass arguments directly to the external diff program: $ svn diff --diff-cmd /usr/bin/diff -x "-i -b" COMMITTERS Index: COMMITTERS = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 0a1,2 > This is a test >
Synopsissvn export [-r REV] URL [PATH] svn export PATH1 PATH2 DescriptionThe first form exports a clean directory tree from the repository specified by URL, at revision REV if it is given, otherwise at HEAD, into PATH. If PATH is omitted, the last component of the URL is used for the local directory name. The second form exports a clean directory tree from the working copy specified by PATH1 into PATH2. All local changes will be preserved, but files not under version control will not be copied. Alternate NamesNone ChangesLocal disk Accesses RepositoryOnly if exporting from a URL Switches--revision (-r) REV --quiet (-q) --force --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesExport from your working copy (doesn't print every file and directory): $ svn export a-wc my-export Export complete. Export directly from the repository (prints every file and directory): $ svn export file:///tmp/repos my-export A my-export/test A my-export/quiz ... Exported revision 15.
Synopsissvn help [SUBCOMMAND...] DescriptionDisplays Help documentation. This is your best friend when you're using Subversion and this book isn't within reach! Alternate Names?, h ChangesNothing Accesses RepositoryNo Switches--version --quiet (-q)
Synopsissvn import [PATH] URL DescriptionRecursively commits a copy of PATH to URL. If PATH is omitted . is assumed. Parent directories are created in the repository as necessary. Alternate NamesNone ChangesRepository Accesses RepositoryYes Switches--message (-m) TEXT --file (-F) FILE --quiet (-q) --non-recursive (-N) --username USER --password PASS --no-auth-cache --non-interactive --force-log --editor-cmd EDITOR --encoding ENC --config-dir DIR --auto-props --no-auto-props ExamplesThis imports the local directory myproj into the root of your repository: $ svn import -m "New import" myproj http://svn.red-bean.com/repos/test Adding myproj/sample.txt ... Transmitting file data ......... Committed revision 16. This imports the local directory myproj into trunk/vendors in your repository. The directory trunk/vendors need not exist before you import into it svn import will recursively create directories for you: $ svn import -m "New import" myproj \ http://svn.red-bean.com/repos/test/trunk/vendors/myproj Adding myproj/sample.txt ... Transmitting file data ......... Committed revision 19.
Synopsissvn info [PATH...] DescriptionPrints information about paths in your working copy, including:
Alternate NamesNone ChangesNothing Accesses RepositoryNo Switches--targets FILENAME --recursive (-R) --config-dir DIR Examplessvn info shows you all the useful information that it has for items in your working copy. It shows information for files: $ svn info foo.c Path: foo.c Name: foo.c URL: http://svn.red-bean.com/repos/test/foo.c Revision: 4417 Node Kind: file Schedule: normal Last Changed Author: sally Last Changed Rev: 20 Last Changed Date: 2003-01-13 16:43:13 -0600 (Mon, 13 Jan 2003) Text Last Updated: 2003-01-16 21:18:16 -0600 (Thu, 16 Jan 2003) Properties Last Updated: 2003-01-13 21:50:19 -0600 (Mon, 13 Jan 2003) Checksum: /3L38YwzhT93BWvgpdF6Zw= = It will also show information for directories: $ svn info vendors Path: trunk URL: http://svn.red-bean.com/repos/test/vendors Revision: 19 Node Kind: directory Schedule: normal Last Changed Author: harry Last Changed Rev: 19 Last Changed Date: 2003-01-16 23:21:19 -0600 (Thu, 16 Jan 2003)
Synopsissvn list [TARGET...] DescriptionLists each TARGET file and the contents of each TARGET directory as they exist in the repository. If TARGET is a working copy path, the corresponding repository URL will be used. The default TARGET is ., meaning the repository URL of the current working copy directory. With --verbose, the following fields show the status of the item:
Alternate Namesls ChangesNothing Accesses RepositoryYes Switches--revision (-r) REV --verbose (-v) --recursive (-R) --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR Examplessvn list is most useful if you want to see what files a repository has without downloading a working copy: $ svn list http://svn.red-bean.com/repos/test/support README.txt INSTALL examples/ ... Like Unix ls, you can also pass the --verbose switch for additional information: $ svn list --verbose file:///tmp/repos 16 sally 28361 Jan 16 23:18 README.txt 27 sally 0 Jan 18 15:27 INSTALL 24 harry Jan 18 11:27 examples/ For further details, see Section 3.6.4.
Synopsissvn log [PATH] svn log URL [PATH...] DescriptionThe default target is the path of your current directory. If no arguments are supplied, svn log shows the log messages for all files and directories inside of (and including) the current working directory of your working copy. You can refine the results by specifying a path, one or more revisions, or any combination of the two. The default revision range for a local path is BASE:1. If you specify a URL alone, then it prints log messages for everything that the URL contains. If you add paths past the URL, only messages for those paths under that URL will be printed. The default revision range for a URL is HEAD:1. With --verbose, svn log will also print all affected paths with each log message. With --quiet, svn log will not print the log message body itself (this is compatible with --verbose). Each log message is printed just once, even if more than one of the affected paths for that revision were explicitly requested. Logs follow copy history by default. Use --stop-on-copy to disable this behavior, which can be useful for determining branch points. Alternate NamesNone ChangesNothing Accesses RepositoryYes Switches--revision (-r) REV --quiet (-q) --verbose (-v) --targets FILENAME --stop-on-copy --incremental --xml --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesYou can see the log messages for all the paths that changed in your working copy by running svn log from the top: $ svn log ------------------------------------------------------------------------ r20 | harry | 2003-01-17 22:56:19 -0600 (Fri, 17 Jan 2003) | 1 line Tweak. ------------------------------------------------------------------------ r17 | sally | 2003-01-16 23:21:19 -0600 (Thu, 16 Jan 2003) | 2 lines ... Examine all log messages for a particular file in your working copy: $ svn log foo.c ------------------------------------------------------------------------ r32 | sally | 2003-01-13 16:43:13 -0600 (Mon, 13 Jan 2003) | 1 line Added defines. ------------------------------------------------------------------------ r28 | sally | 2003-01-07 21:48:33 -0600 (Tue, 07 Jan 2003) | 3 lines ... If you don't have a working copy handy, you can log a URL: $ svn log http://svn.red-bean.com/repos/test/foo.c ------------------------------------------------------------------------ r32 | sally | 2003-01-13 16:43:13 -0600 (Mon, 13 Jan 2003) | 1 line Added defines. ------------------------------------------------------------------------ r28 | sally | 2003-01-07 21:48:33 -0600 (Tue, 07 Jan 2003) | 3 lines ... If you want several distinct paths underneath the same URL, you can use the URL [PATH...] syntax. $ svn log http://svn.red-bean.com/repos/test/ foo.c bar.c ------------------------------------------------------------------------ r32 | sally | 2003-01-13 16:43:13 -0600 (Mon, 13 Jan 2003) | 1 line Added defines. ------------------------------------------------------------------------ r31 | harry | 2003-01-10 12:25:08 -0600 (Fri, 10 Jan 2003) | 1 line Added new file bar.c ------------------------------------------------------------------------ r28 | sally | 2003-01-07 21:48:33 -0600 (Tue, 07 Jan 2003) | 3 lines ... That is the same as explicitly placing both URLs on the command line: $ svn log http://svn.red-bean.com/repos/test/foo.c \ http://svn.red-bean.com/repos/test/bar.c ... When you're concatenating the results of multiple calls to the log command, you may want to use the --incremental switch. svn log normally prints out a dashed line at the beginning of a log message, after each subsequent log message, and following the final log message. If you ran svn log on a range of two revisions, you would get the following: $ svn log -r 14:15 ------------------------------------------------------------------------ r14 | ... ------------------------------------------------------------------------ r15 | ... ------------------------------------------------------------------------ However, if you wanted to gather two nonsequential log messages into a file, you might do something such as this: $ svn log -r 14 > mylog $ svn log -r 19 >> mylog $ svn log -r 27 >> mylog $ cat mylog ------------------------------------------------------------------------ r14 | ... ------------------------------------------------------------------------ ------------------------------------------------------------------------ r19 | ... ------------------------------------------------------------------------ ------------------------------------------------------------------------ r27 | ... ------------------------------------------------------------------------ You can avoid the clutter of the double-dashed lines in your output by using the incremental switch: $ svn log --incremental -r 14 > mylog $ svn log --incremental -r 19 >> mylog $ svn log --incremental -r 27 >> mylog $ cat mylog ------------------------------------------------------------------------ r14 | ... ------------------------------------------------------------------------ r19 | ... ------------------------------------------------------------------------ r27 | ... The --incremental switch provides similar output control when using the --xml switch.
Synopsissvn merge sourceURL1[@N] sourceURL2[@M] [WCPATH] svn merge -r N:M SOURCE [PATH] DescriptionIn the first form, the source URLs are specified at revisions N and M. These are the two sources to be compared. The revisions default to HEAD if omitted. In the second form, SOURCE can be a URL or working copy item, in which case the corresponding URL is used. This URL, at revisions N and M, defines the two sources to be compared. WCPATH is the working copy path that will receive the changes. If WCPATH is omitted, a default value of . is assumed, unless the sources have identical basenames that match a file within, in which case the differences will be applied to that file. Unlike svn diff, the merge command takes the ancestry of a file into consideration when performing a merge operation. This is very important when you're merging changes from one branch into another and you've renamed a file on one branch but not the other. Alternate NamesNone ChangesWorking copy Accesses RepositoryOnly if working with URLs Switches--revision (-r) REV --non-recursive (-N) --quiet (-q) --force --dry-run --diff3-cmd CMD --ignore-ancestry --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesMerge a branch back into the trunk (assuming that you have a working copy of the trunk, and that the branch was created in revision 250): $ svn merge -r 250:HEAD http://svn.red-bean.com/repos/branches/my-branch U myproj/tiny.txt U myproj/thhgttg.txt U myproj/win.txt U myproj/flo.txt If you branched at revision 23, and you want to merge changes on trunk into your branch, you could do this from inside the working copy of your branch: $ svn merge -r 23:30 file:///tmp/repos/trunk/vendors U myproj/thhgttg.txt ... To merge changes to a single file: $ cd myproj $ svn merge -r 30:31 thhgttg.txt U thhgttg.txt
Synopsissvn mkdir PATH... svn mkdir URL... DescriptionCreates a directory with a name given by the final component of the PATH or URL. A directory specified by a working copy PATH is scheduled for addition in the working copy. A directory specified by a URL is created in the repository via an immediate commit. Multiple directory URLs are committed atomically. In both cases all the intermediate directories must already exist. Alternate NamesNone ChangesWorking copy, repository if operating on a URL Accesses RepositoryOnly if operating on a URL Switches--message (-m) TEXT --file (-F) FILE --quiet (-q) --username USER --password PASS --no-auth-cache --non-interactive --editor-cmd EDITOR --encoding ENC --force-log --config-dir DIR ExamplesCreate a directory in your working copy: $ svn mkdir newdir A newdir Create one in the repository (instant commit, so a log message is required): $ svn mkdir -m "Making a new dir." http://svn.red-bean.com/repos/newdir Committed revision 26.
Synopsissvn move SRC DST DescriptionThis command moves a file or directory in your working copy or in the repository. This command is equivalent to an svn copy followed by svn delete. Subversion does not support moving between working copies and URLs. In addition, you can only move files within a single repository Subversion does not support cross-repository moving:
Alternate Namesmv, rename, ren ChangesWorking copy, repository if operating on a URL Accesses RepositoryOnly if operating on a URL Switches--message (-m) TEXT --file (-F) FILE --revision (-r) REV --quiet (-q) --force --username USER --password PASS --no-auth-cache --non-interactive --editor-cmd EDITOR --encoding ENC --force-log --config-dir DIR ExamplesMove a file in your working copy: $ svn move foo.c bar.c A bar.c D foo.c Move a file in the repository (an immediate commit, so it requires a commit message): $ svn move -m "Move a file" http://svn.red-bean.com/repos/foo.c \ http://svn.red-bean.com/repos/bar.c Committed revision 27.
Synopsissvn propdel PROPNAME [PATH...] svn propdel PROPNAME --revprop -r REV [URL] DescriptionRemoves properties from files, directories, or revisions. The first form removes versioned properties in working copy, while the second removes unversioned remote properties on a repository revision. Alternate Namespdel, pd ChangesWorking copy, repository only if operating on a URL Accesses RepositoryOnly if operating on a URL Switches--quiet (-q) --recursive (-R) --revision (-r) REV --revprop --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesDelete a property from a file in your working copy: $ svn propdel svn:mime-type some-script property 'svn:mime-type' deleted from 'some-script'. Delete a revision property: $ svn propdel --revprop -r 26 release-date property 'release-date' deleted from repository revision '26'
Synopsissvn propedit PROPNAME PATH... svn propedit PROPNAME --revprop -r REV [URL] DescriptionEdits one or more properties using your favorite editor. The first form edits versioned properties in your working copy, while the second edits unversioned remote properties on a repository revision. Alternate Namespedit, pe ChangesWorking copy, repository only if operating on a URL Accesses RepositoryOnly if operating on a URL Switches--revision (-r) REV --revprop --username USER --password PASS --no-auth-cache --non-interactive --encoding ENC --editor-cmd EDITOR --config-dir DIR Examplessvn propedit makes it easy to modify properties that have multiple values: $ svn propedit svn:keywords foo.c <svn will launch your favorite editor here, with a buffer open containing the current contents of the svn:keywords property. You can add multiple values to a property easily here by entering one value per line.> Set new value for property 'svn:keywords' on 'foo.c'
Synopsissvn propget PROPNAME [PATH...] svn propget PROPNAME --revprop -r REV [URL] DescriptionPrints the value of a property on files, directories, or revisions. The first form prints the versioned property of an item or items in your working copy, while the second prints unversioned remote property on a repository revision. See Section 7.2 for more information on properties. Alternate Namespget, pg ChangesWorking copy, repository only if operating on a URL Accesses RepositoryOnly if operating on a URL Switches--recursive (-R) --revision (-r) REV --revprop --strict --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesExamine a property of a file in your working copy: $ svn propget svn:keywords foo.c Author Date Rev The same goes for a revision property: $ svn propget svn:log --revprop -r 20 Began journal.
Synopsissvn proplist [PATH...] svn proplist --revprop -r REV [URL] DescriptionLists all properties on files, directories, or revisions. The first form lists versioned properties in working copy, while the second lists unversioned remote properties on a repository revision. Alternate Namesplist, pl ChangesWorking copy, repository only if operating on a URL Accesses RepositoryOnly if operating on a URL Switches--verbose (-v) --recursive (-R) --revision (-r) REV --quiet (-q) --revprop --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesYou can use proplist to see the properties on an item in your working copy: $ svn proplist foo.c Properties on 'foo.c': svn:mime-type svn:keywords owner But with the --verbose flag, svn proplist is extremely handy as it also shows you the values for the properties: $ svn proplist --verbose foo.c Properties on 'foo.c': svn:mime-type : text/plain svn:keywords : Author Date Rev owner : sally
Synopsissvn propset PROPNAME [PROPVAL | -F VALFILE] PATH... svn propset PROPNAME --revprop -r REV [PROPVAL | -F VALFILE] [URL] DescriptionSets PROPNAME to PROPVAL on files, directories, or revisions. The first example creates a versioned, local property change in the working copy, and the second creates an unversioned, remote property change on a repository revision.
Alternate Namespset, ps ChangesWorking copy, repository only if operating on a URL Accesses RepositoryOnly if operating on a URL Switches--file (-F) FILE --quiet (-q) --revision (-r) REV --targets FILENAME --recursive (-R) --revprop --username USER --password PASS --no-auth-cache --non-interactive --encoding ENC --force --config-dir DIR ExamplesSet the mimetype on a file: $ svn propset svn:mime-type image/jpeg foo.jpg property 'svn:mime-type' set on 'foo.jpg' On a Unix system, if you want a file to have the executable permission set: $ svn propset svn:executable ON somescript property 'svn:executable' set on 'somescript' Perhaps you have an internal policy to set certain properties for the benefit of your coworkers: $ svn propset owner sally foo.c property 'owner' set on 'foo.c' If you made a mistake in a log message for a particular revision and want to change it, use --revprop and set svn:log to the new log message: $ svn propset --revprop -r 25 svn:log "Journaled about trip to New York." property 'svn:log' set on repository revision '25' Or, if you don't have a working copy, you can provide a URL. $ svn propset --revprop -r 26 svn:log "Document nap." http://svn.red-bean.com/repos property 'svn:log' set on repository revision '25' Lastly, you can tell propset to take its input from a file. You could even use this to set the contents of a property to something binary: $ svn propset owner-pic -F sally.jpg moo.c property 'owner-pic' set on 'moo.c'
Synopsissvn resolved PATH... DescriptionRemoves conflicted state on working copy files or directories. This routine does not semantically resolve conflict markers; it merely removes conflict-related artifact files and allows PATH to be committed again; that is, it tells Subversion that the conflicts have been resolved. See Section 3.5.4 for an in-depth look at resolving conflicts. Alternate NamesNone ChangesWorking copy Accesses RepositoryNo Switches--targets FILENAME --recursive (-R) --quiet (-q) --config-dir DIR ExamplesIf you get a conflict on an update, your working copy sprouts three new files: $ svn update C foo.c Updated to revision 31. $ ls foo.c foo.c.mine foo.c.r30 foo.c.r31 Once you've resolved the conflict and foo.c is ready to be committed, run svn resolved to let your working copy know you've taken care of everything.
Synopsissvn revert PATH... DescriptionReverts any local changes to a file or directory and resolves any conflicted states. svn revert will not only revert the contents of an item in your working copy, but also any property changes. Finally, you can use it to undo any scheduling operations that you may have done (e.g., files scheduled for addition or deletion can be unscheduled). Alternate NamesNone ChangesWorking copy Accesses RepositoryNo Switches--targets FILENAME --recursive (-R) --quiet (-q) --config-dir DIR ExamplesDiscard changes to a file: $ svn revert foo.c Reverted foo.c If you want to revert a whole directory of files, use the --recursive flag: $ svn revert --recursive . Reverted newdir/afile Reverted foo.c Reverted bar.txt Lastly, you can undo any scheduling operations: $ svn add mistake.txt whoops A mistake.txt A whoops A whoops/oopsie.c $ svn revert mistake.txt whoops Reverted mistake.txt Reverted whoops $ svn status ? mistake.txt ? whoops
Synopsissvn status [PATH...] DescriptionPrints the status of working copy files and directories. With no arguments, it prints only locally modified items (no repository access). With --show-updates, add working revision and server out-of-date information. With --verbose, print full revision information on every item. The first five columns in the output are each one character wide, and each column gives you information about different aspects of each working copy item. The first column indicates that an item was added, deleted, or otherwise changed.
The second column tells the status of a file's or directory's properties.
The third column is populated only if the working copy directory is locked.
The fourth column is populated only if the item is scheduled for addition-with-history.
The fifth column is populated only if the item is switched relative to its parent (see Section 4.5).
The out-of-date information appears in the eighth column (only if you pass the --show-updates switch).
The remaining fields are variable width and delimited by spaces. The working revision is the next field if the --show-updates or --verbose switches are passed. If the --verbose switch is passed, the last committed revision and last committed author are displayed next. The working copy path is always the final field, so it can include spaces. Alternate Namesstat, st ChangesNothing Accesses RepositoryOnly if using --show-updates Switches--show-updates (-u) --verbose (-v) --non-recursive (-N) --quiet (-q) --no-ignore --username USER --password PASS --no-auth-cache --non-interactive --config-dir ExamplesThis is the easiest way to find out what changes you have made to your working copy: $ svn status wc M wc/bar.c A + wc/qax.c If you want to find out what files in your working copy are out-of-date, pass the --show-updates switch (this will not make any changes to your working copy). Here you can see that wc/foo.c has changed in the repository since we last updated our working copy: $ svn status --show-updates wc M 965 wc/bar.c * 965 wc/foo.c A + 965 wc/qax.c Status against revision: 981
And finally, the most information you can get out of the status subcommand: $ svn status --show-updates --verbose wc M 965 938 sally wc/bar.c * 965 922 harry wc/foo.c A + 965 687 harry wc/qax.c 965 687 harry wc/zig.c Head revision: 981 For many more examples of svn status, see Section 3.5.3.1.
Synopsissvn switch URL [PATH] DescriptionThis subcommand updates your working copy to mirror a new URL usually a URL which shares a common ancestor with your working copy, although not necessarily. This is the Subversion way to move a working copy to a new branch. See Section 4.5 for an in-depth look at switching. Alternate Namessw ChangesWorking copy Accesses RepositoryYes Switches--revision (-r) REV --non-recursive (-N) --quiet (-q) --diff3-cmd CMD --relocate --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesIf you're currently inside the directory vendors which was branched to vendors-with-fix and you'd like to switch your working copy to that branch: $ svn switch http://svn.red-bean.com/repos/branches/vendors-with-fix . U myproj/foo.txt U myproj/bar.txt U myproj/baz.c U myproj/qux.c Updated to revision 31. And to switch back, just provide the URL to the location in the repository from which you originally checked out your working copy: $ svn switch http://svn.red-bean.com/repos/trunk/vendors . U myproj/foo.txt U myproj/bar.txt U myproj/baz.c U myproj/qux.c Updated to revision 31.
If the location of your repository changes and you have an existing working copy that you'd like to continue to use, you can use svn switch relocate to change your working copy from one URL to another: $ svn checkout file:///tmp/repos test A test/a A test/b ... $ mv repos newlocation $ cd test/ $ svn update svn: Unable to open an ra_local session to URL svn: Unable to open repository 'file:///tmp/repos' $ svn switch --relocate file:///tmp/repos file:///tmp/newlocation . $ svn update At revision 3.
Synopsissvn update [PATH...] Descriptionsvn update brings changes from the repository into your working copy. If no revision given, it brings your working copy up-to-date with the HEAD revision. Otherwise, it synchronizes the working copy to the revision given by the --revision switch. For each updated item a line will start with a character reporting the action taken. These characters have the following meaning:
A character in the first column signifies an update to the actual file, while updates to the file's properties are shown in the second column. Alternate Namesup ChangesWorking copy Accesses RepositoryYes Switches--revision (-r) REV --non-recursive (-N) --quiet (-q) --diff3-cmd CMD --username USER --password PASS --no-auth-cache --non-interactive --config-dir DIR ExamplesPick up repository changes that have happened since your last update: $ svn update A newdir/toggle.c A newdir/disclose.c A newdir/launch.c D newdir/README Updated to revision 32. You can also update your working copy to an older revision (Subversion doesn't have the concept of sticky files like CVS does; see Appendix A): $ svn update -r30 A newdir/README D newdir/toggle.c D newdir/disclose.c D newdir/launch.c U foo.c Updated to revision 30. If you want to examine an older revision of a single file, you may want to use svn cat. |