Skip to content

Instantly share code, notes, and snippets.

@Paulmicha
Created October 24, 2012 10:34
Show Gist options
  • Save Paulmicha/3945381 to your computer and use it in GitHub Desktop.
Save Paulmicha/3945381 to your computer and use it in GitHub Desktop.
Svn - Versionnig of a project with existing sources (+ how to remove all ".svn" dirs recursively)
#!/bin/bash
# -*- coding: UTF8 -*-
##
# SVN shell commands cheat sheet
# Tested in Debian 6 ("Squeeze")
#
# Prerequisites : svn server & repository
#
# Sources :
# http://stackoverflow.com/questions/3155250/release-locks-in-subversion-recursively
# http://blog.muhuk.com/2012/03/16/installing-subversion-1-7-on-debian-squeeze-via-apt.html
#
#------------------------------------------------------------------------------------------
# Unlocking / Cleaning up
# Easiest way : run 'svn cleanup' to remove locks
svn cleanup
# If you really have to :
# a) When the lock is local
svn unlock path/to/locked-ressource
# b) When the lock is distant
svn unlock http://SVN.SERVER/svn/MY.PROJECT/trunk/
# or
svn unlock --force http://SVN.SERVER/svn/MY.PROJECT/trunk/
#------------------------------------------------------------------------------------------
# Upgrading from SVN 1.6 to 1.7 under Debian 6 "Squeeze"
echo '# update SVN to 1.7
deb http://opensource.wandisco.com/debian/ squeeze svn17' >> /etc/apt/sources.list
# Add key
wget http://opensource.wandisco.com/wandisco-debian.gpg
apt-key add wandisco-debian.gpg
# Update && upgrade package "subversion"
aptitude update
aptitude upgrade subversion
#------------------------------------------------------------------------------------------
# Versionnig of a project with existing sources
# Cd to project path
cd /var/www/MY/PROJECT
# Safety first : backup all files
tar -zcvf backup_files_before_versionning.tgz .
# Send all files into repo
svn import -m "initial import" http://SVN.SERVER/svn/MY.PROJECT/trunk/ $SVNROOT
# Alternative - we may want to only send a sub-dir :
cd MY/SUBDIR
svn import -m "initial import" http://SVN.SERVER/svn/MY.PROJECT/trunk/MY/SUBDIR/ $SVNROOT
cd ../../
# Quick'n'dirty checkout - Overwrites evertything in order to create the ".svn" dirs in place
svn checkout http://SVN.SERVER/svn/MY.PROJECT/trunk . --force
# There's a good chance this last operation messed up file permissions.
# -> Reset files' owner, group & permission
chown MYOWNER:MYGROUP . -R
chmod 775 . -R
#------------------------------------------------------------------------------------------
# Disaster recovery : how to remove all ".svn" dirs recursively
cd /var/www/MY/PROJECT
find . -depth -type d -name "*\.svn" -exec rm -rf {} +
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment