Subversion (SVN)

Install SVN 1.5

*Download and unzip Subversion 1.5 binary built for Apache 2.2 (svn-win32-1.5.5.zip) from here
*Create a new env variable: SVN_HOME=C:\prog\svn-win32-1.5.5
*Add %SVN_HOME%\bin to PATH: path=%SVN_HOME%\bin;%path%

SVN_HOME=C:\prog\svn-win32-1.5.5
path=%SVN_HOME%\bin;%path%

Create Repository

svnadmin create C:\work\svn

Eclipse plugin: Subclipse

* Eclipse update site URL: http://subclipse.tigris.org/update_1.4.x
* Install all
* Restart Eclipse
* Open SVN Perspective: SVN Repository Exploring. Add a SVN Repository location.
* Right click an Eclipse project, select the Team menu for SVN operations.

Install SVN on Apache 2

* See here for details.

Remove all subversion directories

Sometimes you want to remove a directory structure from subversion control. Simple remove all .svn folders. You can also use the following Ant target to do that. Important note is that you need to set defaultexcludes to false since .svn is one of the default excludes for Ant.

  <!-- - - - - - - - - - - - - - - - - - 
          target: remove-svn                      
         - - - - - - - - - - - - - - - - - -->
    <target name="remove-svn">
      <delete includeemptydirs="true">
      <fileset dir="${basedir}" defaultexcludes="false">
          <include name="**/.svn/**"/>
      </fileset>
    </delete>
    </target>

Repository Access URLs

file:///
file:///x:/path/to/repos
http://
https://
svn://
svn+ssh://

Commands

Help

svn help 

Create a repository

svnadmin create C:\svn\repos1

List

svn list file:///c:/svn/repos1

Import

* Create directory structure to be imported.

project
-trunk
--mydir
---myfile.txt
-tags
-branches

* Go to project’s parent directory and issue import command:

svn import project file:///c:/svn/repos1/project1 -m "Initial import of my project"
Adding         project\trunk
Adding         project\trunk\mydir
Adding         project\trunk\mydir\myfile.txt
Adding         project\branches
Adding         project\tags

Committed revision 1.

Checkout project

svn checkout file:///c:/svn/repos1/project1/trunk/mydir
A    mydir\myfile.txt
Checked out revision 1.

Checkout a particular revision

svn checkout --revision 1 file:///c:/svn/repos1/project1/trunk
A    trunk\mydir
A    trunk\mydir\myfile.txt
Checked out revision 1.

Update file

svn update

Update to a particular revision

svn update --revision 2
U    mydir\myfile.txt
Updated to revision 2.

Commit modified file

* Modify myfile.txt.
* Under mydir directory:

svn commit -m "Modified myfile.txt"
Sending        myfile.txt
Transmitting file data .
Committed revision 2.

View log

svn log myfile.txt
------------------------------------------------------------------------
r1 | JianmingLi | 2009-04-20 13:41:43 -0400 (Mon, 20 Apr 2009) | 1 line

Initial import of my project
------------------------------------------------------------------------

C:\Temp\svnwork\mydir>svn log myfile.txt
------------------------------------------------------------------------
r2 | JianmingLi | 2009-04-20 14:09:25 -0400 (Mon, 20 Apr 2009) | 1 line

Modified myfile.txt
------------------------------------------------------------------------
r1 | JianmingLi | 2009-04-20 13:41:43 -0400 (Mon, 20 Apr 2009) | 1 line

Initial import of my project
------------------------------------------------------------------------

svn log --revision 1:2
svn log -r 1:2

Add a new file to repository

* Create a new file in mydir directory.
* In mydir directory:

svn add addfile.txt
A         addfile.txt

svn commit -m "Add addfile.txt"
Adding         addfile.txt
Transmitting file data .
Committed revision 3.

Add all new files

svn add * --force

Copy file

* In mydir directory:

svn copy addfile.txt copyfile.txt
A         copyfile.txt

svn commit -m "Copy addfile to copyfile.txt"
Adding         copyfile.txt

Committed revision 4.

Delete file

svn delete addfile.txt
D         addfile.txt

svn commit -m "Delete addfile"
Deleting       addfile.txt

Committed revision 5.

Diff file

C:\Temp\svnwork\mydir>svn diff myfile.txt
Index: myfile.txt
=========================================
--- myfile.txt  (revision 2)
+++ myfile.txt  (working copy)
@@ -1 +1 @@
-modified text.
\ No newline at end of file
+modified text. modified again.
\ No newline at end of file

Revert changes

svn revert myfile.txt
Reverted 'myfile.txt'

svn diff myfile.txt

Print out a particular revision

svn cat --revision 1 myfile.txt
initial text.
svn cat --revision 2 myfile.txt
modified text.

List repository files

svn list file:///c:/svn/repos1/project1/trunk
mydir/

svn list file:///c:/svn/repos1/project1/trunk/mydir
copyfile.txt
myfile.txt

Cleanup work directory

svn cleanup

Backup repository

svnadmin hotcopy path/to/repo path/to/backup --clean-logs

References
SVN cheat sheet

This entry was posted in scm, svn, win. Bookmark the permalink.