Helpful tips and tricks for configuring and using Subversion (SVN) are provided below.
Global configuration changes...
NOTE: WIP.
The following commands have more common usecases used outside of initial setup.
Clone a remote repository onto your local machine.
svn checkout [-r<revision_number>] <repository_url> [<destination_path>]NOTE: The optional <revision_number> parameter specifies the specific revision to be checked out.
NOTE: The <repository_url> parameter specifies the URL of the repository to be checked out.
NOTE: The optional <destination_path> parameter specifies the path into which the repository will be cloned.
Change the branch of the current local repository to the specified branch.
svn switch <branch_url>NOTE: The <branch_url> parameter is the URL of the branch to which the local repository will switch.
Change the current local branch to the specified revision.
svn up -r<revision_number>NOTE: The <revision_number> parameter is the revision to which the current branch of the local repository will change.
Merge the branch at the specified URL into the current local branch.
svn merge [-r<start_revision_number - 1>:<end_revision_number>] <branch_url>NOTE: The optional <start_revision_number - 1> parameter is the number of the revision preceding the range of revisions to be merged.
NOTE: The optional <end_revision_number> parameter is the number of the final revision to be merged.
NOTE: The <branch_url> parameter is the URL of the branch to be merged into the current local branch.
WARNING: Due to the way SVN manages conflict resolution during a merge, it is preferred to merge one changeset at a time. If a conflict arises, even after resolution, SVN returns to a stable state without completing the merge of subsequent revisions.
Generate a patchset from the current collection of uncommitted changes.
svn diff > <patch_file_path>NOTE: The <patch_file_path> parameter is the path to the patchset file to be created.
Generate a patchset from the current collection of uncommitted changes.
svn diff > ../myrepo_branch1_patchset_2020-01-13_1.diffApply a changeset from the specified patch file to the current local branch.
svn patch <patch_file_path>NOTE: The <patch_file_path> parameter is the path to the file containing the patchset to be applied.
Apply a changeset from the specified patch file to the current local branch.
svn patch ../myrepo_branch1_patchset_2020-01-13_1.diffUpdate the associated remote branch with changes from the current local branch.
svn commitUpdate the local branch to the latest version stored on the remote server.
svn update [-r<revision_number>]NOTE: The optional <revision_number> parameter specified the revision on the remote to which the current local branch should be updated.
Show the blame information for the specified targets.
svn annotate ...Remove new uncommitted files from the specified path of the current branch of the local repository.
svn cleanup <path> --remove-unversionedNOTE: The <path> parameter is the relative path to the parent directory from which uncommitted files should be removed.
NOTE: This operation is applied recursively.
Remove new uncommitted files from the current directory and any descendant directories.
svn cleanup . --remove-unversionedUndo all uncommitted changes from files in the specified path of the current branch of the local repository.
svn revert --recursive <path>Alternatively,
svn revert -R <path>NOTE: The <path> parameter is the relative path to the parent directory from which uncommitted changes should be reverted.
NOTE: This operation is ONLY applied recursively when the -R/--recursive argument is specified.
Undo all uncommitted changes from files in the current directory and any descendant directories.
svn revert -R .Log the most-recent N commits.
svn log [--limit <N>]NOTE: The optional <N> parameter specifies the number of commits to which the log should be limited.
Log the most-recent 5 commits.
svn log --limit 5Get the repository and branch URL, as well as the current revision information.
svn infoGet the list of files containing merge conflicts.
svn status | grep -P '^(?=.{0,6}C)'NOTE: Referenced from StackOverflow (https://stackoverflow.com/questions/2882786/is-there-a-command-to-list-svn-conflicts).
Mark the merge conflict in the specified file as resolved.
svn resolve --accept=working <file_path>NOTE: The <file_path> parameter is the path for the file whose conflicts should be considered resolved.
Get the status of the local repository (X means clean)
svn statusThe first column in the svn status response indicates that the corresponding item was added, deleted, or otherwised changed according to the following table.
| Character | Meaning |
|---|---|
' ' |
No modification. |
A |
Item is scheduled for addition. |
D |
Item is scheduled for deletion. |
M |
Item has been modified. |
R |
Item has been replaced in the working copy. This means the file was scheduled for deletion, and then a new file with the same name was scheduled for addition in its place. |
C |
The contents--as opposed to the properties--of the item conflict with updates received from the remote repository. |
X |
Item is present due to an externals definition. |
I |
Item is being ignored (e.g. via the svn:ignore property). |
? |
Item is not under version control. |
! |
Item is missing (e.g. it was moved or deleted without having invoked the appropriate corresponding svn command). This may also indicate a directory is incomplete (a checkout or update command was interrupted). |
~ |
Item is versioned as one kind of object (file, repository, link) but has been replaced by a different kind of object. |
The second column in the svn status response indicates the status of a file's or directory's properties.
| Character | Meaning |
|---|---|
' ' |
No modification. |
M |
Properties for this item have been modified. |
C |
Properties for this item are in conflict with property updates received from the remote repository. |
The third column in the svn status response is populated only if the working copy directory is locked (see the section titled "Sometimes You Just Need to Clean Up").
| Character | Meaning |
|---|---|
' ' |
Item is not locked. |
L |
Item is locked. |
The fourth column in the svn status response is populated only if the item is scheduled for addition-with-history.
| Character | Meaning |
|---|---|
' ' |
No history scheduled with commit. |
+ |
History scheduled with commit. |
The fifth column in the svn status response is populated only if the item is switched relative to its parent (see the section titled "Traversing Branches").
| Character | Meaning |
|---|---|
' ' |
Item is a child of its parent directory. |
S |
Item is switched. |
The sixth column in the svn status response is populated with lock information.
| Character | Meaning |
|---|---|
' ' |
When the --show-updates/-u argument is used, the file is not locked. When that flag is not used, this ONLY means the file is not locked in *this* working copy. |
K |
File is locked in this working copy. |
O |
File is locked--either by another user, or in another working copy. This appears only when the --show-updates/-u argument is used. |
T |
File was locked in this working copy, but the lock has been 'stolen' and is invalid. The file is currently locked in this repository. This appears only when the --show-updates/-u argument is used. |
B |
File was locked in this working copy, but the lock has been 'broken' and is invalid. The file is no longer locked. This appears only when the --show-updates/-u argument is used. |
The seventh column in the svn status response is populated only if the item is the victim of a tree conflict.
| Character | Meaning |
|---|---|
' ' |
Item is not the victim of a tree conflict. |
C |
Item is the victim of a tree conflict. |
The eighth column in the svn status response is always blank.
The ninth column in the svn status response is populated (only if the -u/--show-updates argument is passed to the command) with the out-of-date information.
| Character | Meaning |
|---|---|
' ' |
The item in your working copy is up-to-date. |
* |
A newer revision of the item exists on the server. |