Using ‘grep’ with Subversion

I use ‘grep’ alot, but it false positives when searching in a Subversion working copy. So I’m using the ‘-r’ flag to recursive search for the phrase ‘quick brown fox’:

$ grep -r 'quick brown fox' *
app/controllers/users_controller.php: quick brown fox
app/controllers/.svn/text-base/users_controller.php.svn-base: quick brown fox

This is only a minor annoyance if there are just two entries, but often that’s not the case. The solution is to add the ‘–exclude-dir=.svn’ flag. But the extra characters causes unnecessary fatigue on my fingers, so I’ve added an alias to my .bashrc file:

alias grep='grep --exclude-dir=.svn'

For maximum mileage, combine this with ‘-ir’:

alias grep='grep -ir --exclude-dir=.svn'
Advertisements

Creating a branch in Subversion

Beginning at the root of your repository:

svn mkdir branches/wayne
cd branches/wayne
svn merge http://your.subversion.server/projectName/trunk
svn ci -m 'Issuing "svn merge http://your.subversion.server/projectName/trunk".'

Subversion help

Let’s suppose I’ve designated my Subversion repository to be /home/svn/.

Now I want to create a project “wordpress”:

# svnadmin create /home/svn/wordpress

Assuming you use Apache, make sure that “wordpress” is owned by the Apache user; e.g. nobody.

# chown -R nobody:nobody /home/svn/wordpress

Now go to the “wordpress” directory that you wish to Subversion.

# cd /home/kzhiwei/wordpress/

Note that this is distinct from the Subversion project folder that was created previously. Then import:

# svn import . file:///home/svn/wordpress

You should get a whole bunch of messages listing the files that have been imported from /home/kzhiwei/wordpress/ into /home/svn/wordpress/.