We use Apache Subversion for version control. For a complete reference on Subversion see the Subversion Book. You can browse our repository in your web browser.
This page gives instructions on performing basic development tasks using the Subversion Command-Line Client. This instruction assumes you have Apache Subversion installed.
You begin using Subversion by copying a directory from a remote repository to a local directory on your file system. This is known as a checkout of a working copy.
Subversion uses a copy-modify-merge model meaning that you can add and edit files and directories in your working copy like any other files on your system, but you should use subversion commands for everything else such as svn copy
and svn move
instead of the operating system commands.
Subversion commands can be run from a command shell such as Bash on Linux. The subversion client command is svn
followed by optional sub-commands, options, and arguments.
Show the program version and modules
$ svn --version
Run a sub-command
$ svn <subcommand> [options] [args]
Most sub-commands take file and/or directory arguments, recursing on the directories. If no arguments are supplied to such a command, it recurses on the current directory (inclusive) by default. (from svn help
)
The following is only a partial list of sub-commands relating to this instruction. For a complete list, see the Subversion Book, or use svn help
.
add
- Schedule a new file or directory (including contained files) for inclusion in the repositorycheckout
, co
- Create a local working copy of a remote repositorycommit
, ci
- Commit (check in) local changes to the repositorycopy
, cp
- Copy one or more files in a working copy or in the repositorydelete
, del
, remove
, rm
- Items specified are scheduled for deletion upon the next commit. Working copy files not yet committed are deleted immediately.diff
, di
- Displays differences in files from the directoryhelp
, ?
, h
- Subversion help and help on sub-commandsmove
, mv
, rename
, ren
- Moves files or directories in your working copy or repositoryresolve
- Resolve conflicts on working copy files or directoriesrevert
- Undo all local edits or optionally a file or directorystatus
- Print the status of working copy files and directoriesupdate
- Bring changes from the repository into your working copyCommitters need to configure their Subversion client to handle the differences in line endings of text files on different operating systems.
There are instances where Subversion may need to open an editor. You need to have the environment variable EDITOR set to the editor you would like to use. To set it for the current terminal session in Bash (your path may differ):
$ export EDITOR=/usr/bin/vim
The Odf repository layout uses the following top-level directories branches
, site
, tags
, and trunk
.
branches
- Contains branches used for continued development of a specific version, experimental versions, or for developing features to be merged into the trunk or a branch later. (needs examples)site
- Contains the web site source code. Also contains it's own trunk directory.tags
- Contains specific versions of the project. These tags are not to be revised. (needs examples)trunk
- Contains the current source code.
For more information see the Contributors Tech Guide.From the parent directory of where you want the working copy. In this example the odf-trunk
directory will be created if it does not exist.
$ svn co https://svn.apache.org/repos/asf/incubator/odf/trunk odf-trunk A odf-trunk/tools A odf-trunk/tools/dev A odf-trunk/tools/dev/fetch-all-cws.sh A odf-trunk/tools/dev/cws-list.txt A odf-trunk/tools/dev/fetch-all-web.sh A odf-trunk/tools/dev/web-list.txt A odf-trunk/tools/dev/single-hg.sh Checked out revision 1145818.
"A" indicates file or directory is "Added" to working copy
svn update
commandsvn add
, svn delete
, svn copy
, svn-move
commandssvn status
and svn diff
svn revert
to restore files or directories to an unmodified statesvn update
command to bring your copy up to date. This may create a local conflict where someone may have added a file with a name that you also want to add, or may have made changes to the same line of a file as you. For this use the svn resolve
command.svn commit
commandAfter creating the file "test-file.txt" in the working copy.
$ svn status ? test-file.txt
? indicates test-file.txt is not under version control
$ svn add test-file.txt A test-file.txt $ svn status A test-file.txt
"A" indicates file is scheduled for addition
$ svn diff Index: test-file.txt =================================================================== --- test-file.txt (revision 0) +++ test-file.txt (revision 0) @@ -0,0 +1 @@ +This is a test file for svn-basics. Property changes on: test-file.txt ___________________________________________________________________ Added: svn:eol-style + native
$ svn commit test-file.txt -m "added test-file.txt" Adding test-file.txt Transmitting file data . Committed revision 2.
$ svn update U test-file.txt Updated to revision 3.
"U" indicates an "Update" to a file or directory
Modify the file (this example uses the vim editor)
$ vim test-file.txt
$ svn status M test-file.txt
"M" indicates the file has been "Modified"
$ svn diff Index: test-file.txt =================================================================== --- test-file.txt (revision 3) +++ test-file.txt (working copy) @@ -1,2 +1,3 @@ This is a test file for svn-basics. This is a new line added by someone else. +This line added by me.
Suppose someone edits the same line as you before you commit
$ svn update Conflict discovered in 'test-file.txt'. Select: (p) postpone, (df) diff-full, (e) edit, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options:
This is just like if you had ran the svn resolve
command
Selecting df
displays this:
--- .svn/text-base/test-file.txt.svn-base Sun Jul 17 17:38:52 2011 +++ .svn/tmp/test-file.txt.tmp Sun Jul 17 21:35:09 2011 @@ -1,2 +1,7 @@ This is a test file for svn-basics. This is a new line added by someone else. +<<<<<<< .mine +This line added by me. +======= +This line is added by someone else also. +>>>>>>> .r4 Select: (p) postpone, (df) diff-full, (e) edit, (r) resolved, (mc) mine-conflict, (tc) theirs-conflict, (s) show all options:
If you choose e
, Subversion will launch an editor with both sets of changes included for you to edit. You can save your changes in the editor and then select r
(for resolved).
G test-file.txt Updated to revision 4.
"G" indicates "merGed"
Only Committers can commit directly to the repository. The following example shows using your Apache ID and password.
$ svn commit test-file.txt --username your-name --password your-password \ -m "added new line" Sending test-file.txt Transmitting file data . Committed revision 5.
For further information see the Basic Work Cycle page from Subversion Book.
See the Applying Patches section of the Committer FAQ page.
Example similar to one on Committer FAQ:
Issue #43835: Added some cool new feature. Submitted by: John Doe <john.doe.at.null.org>
Using the -m (--message)
option only allows a single line log message. To commit a multi-line message use the -F (--file)
option (with a previously created file) or use neither -m or -F and an editor will be started.
See the Sending in Patches section on the Contributors Tech Guide page.
Create the patch file from svn diff
where your-patch-name.patch
is the full path to the patch file to create.
svn diff > your-patch-name.patch
For more information see: