Tag Archives: SVN

My SVN cheat sheet

Here is my “Cheat sheet” for the Subversion version system

Create repository

svnadmin create <project1>

This will create a repository at your current location named “project1”

Import a project locally

svn import /path/to/files/to/import file:///path/to/repository -m "Initial import"

Import a project into remote server (running svnserve on server)

svn import /path/to/files/to/import svn:///path/to/repository -m "Initial import"

Checkout locally

svn co file://<path to repository> <foldername>

<foldername> will be created if it does not exists. NOTE If you are using branches/tags/trunk structure don’t forget to include it in the path (eq. /path/to/repository/trunk).

Checkout remote (with svnserve running on server)

svn co svn://<host/path/to/repository>/<foldername>

Checkout remote (svnserve and authentication)

svn co --username=<user>  svn://<host/path/to/repository>/<folder>

List svn directory (to look at directory contents)

svn list file://<path to repository>/<foldername>

Use ‘svn://…’ for remote ‘look’ in the same way as with checkout. This will display thew latest revision. To see another revision use @revision (at the end of the path)

Commit changes (all files)

svn commit -m"<commit message>"

Commit one file

svn commit -m"<commit message>" filename

To commit more then one file just place their path after the first ‘filename’

Check status of your working copy

svn status

NOTE You have to stand inside the working directory for the command to work

Get info about a repository (eg. URL, root)

svn info

Conflict resolving
Resolvetypes:

  • mine-full: use your version only
  • theirs-full: use the latest version in the repository
  • base: use the version you used before making any changes
  • working: this is the option if you want to do a manual merge of the file. Removing the changes you don’t want and keeping the ones that you want on a row by row basis

Resolve command:

svn resolve --accept resolvetype filename

Ignore files and folders globally
In the section [miscellany] in your subversion conf file (OS X: /User/<username>/.subversion/conf) there is a setting called global-ignores
Example:

global-ignores = .* old *.gz tmp

This ignores hidden files/folders (all which name starts with a dot (.)), all files/folders called old or tmp and all files ending with .gz

Ignore files and folders locally
Run this command from the folder above the files/folders that should be ignored:

svn propedit svn:ignore . #NOTE the last dot!

This opens up your chosen editor (ENV variable EDITOR=editor) so you can add your ignore files/folders. One ignore per line.
Example:

.*
old
*.gz
tmp

When you save and exit the properties are written to that folder

Add folder non recursive
By default svn add is recursive so all files and folders in the folder you add will be added automatically. To just add the one folder and not the content of that folder use the –non-recursive option

svn add --non-recursive foldername

This will only add the folder foldername and not any files or folders inside foldername

Remove all .svn folders from a project

I needed this to “force” a new import into my subversion repository from Netbeans (v7.0) which only shows that option if there are no .svn folders in the project. Here is how I removed all the folders:

find /path/to/project -name ".svn" | xargs rm -rf

This will first find all files in the project named “.svn” and then delete them with the rm -rf command