< BACK TO POST
LinkedIn Facebook Twitter

Blog

Command-line Subversion Practices

March 12th, 2011 | Development , Tips and Tricks , Tutorials

After using many SVN Clients on Windows/Unix/Linux Platforms, I realized that there is no need to use these 3rd party softwares. You can do anything you want using command-line. Lets go...

My defaults:

My Svn Repo : http://svn.geryit.com/geryitcom
Local Folder : ~/Sites/geryitcom
Path to be ignored : ~/Sites/geryitcom/_source

Checkout Repo

cd /Users/geryit/Library/WebServer/
svn co http://svn.geryit.net/geryitcom/
cd geryitcom

Update Repo

svn up

Define Files/Folders to be ignored

Create a path that will be ignored on commit

mkdir _source
svn ps svn:ignore _source .
If you have multiple items (path/file) to be ignored

Create ".ignore" file and add items to be ignored inside (We want to ignore "_source" and "cache" folders)

mkdir _source
mkdir cache
touch .ignore
open .ignore

Add this following lines into .ignore file and save file

 _source
cache

Assign ".ignore" file as ignored items container

svn ps svn:ignore -F .ignore .

Add new files/folders to SVN

svn add . --force

Remove missing files with SVN

svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )

Commit Changes

svn ci -m "Your message"

How to fix svn: Directory '***' is missing problem

Sometimes when you delete a local file/path and SVN Commit, you will see an SVN error like "svn: Directory '/Users/geryit/Library/WebServer/geryitcom/cache' is missing". Then you should :

svn delete cache --force

Create a shell script which does everything for you

Put the code below in a blank text file and save it as "svn_it" in /sbin folder. Now when you run svn_it, it will fire the commands below. You should "sudo chmod 775 /sbin/svn_it" if you face a permission problem

#!/bin/bash
svn up
svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )
svn add . --force
svn ci -m ""

Leave a Reply