SVN For Dummies


# First install SVN server (e.g. svnserve) and client (svn)

# Set up auto propset
vim /etc/subversion/config

# Set the following config
enable-auto-props = yes
*.png = svn:mime-type=image/png
*.gif = svn:mime-type=image/gif
*.jpg = svn:mime-type=image/jpeg
*.ini = svn:keywords=Date Revision Author HeadURL Id;svn:eol-style=native
*.html = svn:keywords=Date Revision Author HeadURL Id;svn:eol-style=native
*.phtml = svn:keywords=Date Revision Author HeadURL Id;svn:eol-style=native
*.php = svn:keywords=Date Revision Author HeadURL Id;svn:eol-style=native
*.js = svn:keywords=Date Revision Author HeadURL Id;svn:eol-style=native
*.css = svn:keywords=Date Revision Author HeadURL Id;svn:eol-style=native

# Create repository
svnadmin /var/svn/repos

# Build the project repository
svn import ~/project file:///var/svn/repos/project -m "Build"

# Start svnserve as daemon
svnserve -d

# Check out
svn checkout file:///var/svn/repos/project ~/working_copy

# Set ID keyword to files
svn propset svn:keywords "Id" *.php
svn propset svn:keywords "Id" *.js
svn propset svn:keywords "Id" *.gif
svn propset svn:keywords "Id" *.jpg
svn propset svn:keywords "Id" *.png
svn propset svn:keywords "Id" *.phtml
svn propset svn:keywords "Id" *.html
svn propset svn:keywords "Id" *.css
svn propset svn:keywords "Id" *.ini

# Or, recursively
find ./ -name '*.phtml' -print0 | xargs -0 svn propset svn:keywords Id

# Next time when you commit, $Id:$ will be updated
svn ci -m "commit"

# Update
svn up

# Check file state
svn st

# Add new files to svn
svn add ~/working_copy/new.php

# Delete file from svn
svn delete ~/working_copy/new.php

# Move/rename file in svn
svn mv ~/working_copy/from.php ~/working_copy/to.php

Leave a Reply