How to use Subversion (SVN) from Command Line
Forenote: This article needs to be revised and may be incomplete, please take care when following it.
Firstly we will create a folder for our SVN Base Dir:
mkdir /SVN cd /SVN
Now we will create a repostitory:
svnadmin create --fs-type fsfs /SVN/MyRepositoryName
We can now import a typical template (or existing project) – for example:
mkdir /tmp/template cd /tmp/template mkdir trunk mkdir branches mkdir tags
Definitions:
Trunk:- Usually reperesents the mainstream development
Branches:- Usually reperesents experimental or new concept code
Tags:- Used to mark specific revisions e.g. version 1 or version 2
and then import them into our repository we created:
-need to add someting here-
To checkout a repositroy use:
svn co file:///SVN/MyRepositoryName tmp
“tmp” is the directroy where the downloaded files will be stored from the repostiroy and this will also be your SVN working directory.
We can now connect to our repository over SSH, to list the file within our repository remotely issue:
svn ls svn+ssh://username@remotehost.com/SVN/MyRepositoryName
or to “CheckOut” the repository we can issue the following command:
svn co svn+ssh://root@localhost/SVN/trunk myproject
Note: The “myproject” part of the command simply defines where checkout will be stored.
Definition – Checkout: This simply means to retrieve a specific copy of the repostiroy or part there of.
We can also directly import files into the repository:
svn import test.htm file:///SVN/trunk/test.htm --message "what / why I am doing this"
The above would simply import test.htm (from the current directory) and place it within /SVN/trunk/ in the repository.
or remotely:
svn import test.htm svn+ssh://username@remotehost.com/SVN/trunk/test.htm --message "what / why I am doing this"
You can also check the status of file within the directroy to see if they have been revised / are up to date:
svn status --verbose
and
svn diff
And to find out information about the SVN directory we use:
svn info
.
In order to add files we use:
svn add examplefile.html
and we then commit the changes:
svn commit -m "byebye"