Monday, May 10, 2010

Working with subversion

Here is a quick summary of svn commands.


Let make few changes to the trunk:
user1@deby:~/project1$ cd trunk/
user1@deby:~/project1/trunk$ mkdir tests
user1@deby:~/project1/trunk$ touch readme.txt tests/readme.txt
Here is how you can status changes made to the current directory:
user1@deby:~/project1/trunk$ svn status
?      tests
?      readme.txt


Now let add these changes to repository:
user1@deby:~/project1/trunk$ svn add *
A         readme.txt
A         tests
A         tests/readme.txt
In order to add folder non recursively, use -N option


Added doesn't mean it now available to everyone to checkout. You need commit your work.
user1@deby:~/project1/trunk$ svn ci -m 'Testing add svn command'
Adding         trunk/readme.txt
Adding         trunk/tests
Adding         trunk/tests/readme.txt
Transmitting file data ..
Committed revision 2.


Deleting files is easy.
user1@deby:~/project1/trunk$ svn rm tests/readme.txt
D         tests/readme.txt
user1@deby:~/project1/trunk$ svn ci -m 'Testing delete svn command'
Deleting       trunk/tests/readme.txt

Committed revision 3.


Reverting deleted files:
user1@deby:~/project1/trunk$ svn rm readme.txt
D         readme.txt
user1@deby:~/project1/trunk$ svn revert readme.txt
Reverted 'readme.txt'

Make changes

Make some changes to readme.txt file and commit your work.
user1@deby:~/project1/trunk$ svn ci -m 'Testing modifications'
Sending        trunk/readme.txt
Transmitting file data .
Committed revision 4.


You can update your local copy with changes made by other team members:
user1@deby:~/project1/trunk$ svn update
At revision 4.


Often your working folder has some files or folders that you would like exclude from svn related operations (ignore), here is how you can get this done:
master@deby:~/project1/trunk$ svn propedit svn:ignore .
Set new value for property 'svn:ignore' on '.'
The above command will open your default editor to setup ignore properties for the current folder (notice '.' in command line). You need to enter file names, folders, etc you need to ignore (one item per line). Once you save changes and exit the editor, svn will update appropriate properties. You can also add settings to svn config file (~/.subversion/config or /etc/subversion/config) to ignore certain file types:
global-ignores = build dist *.pyc *.pyo *.mo

Changes history

If you need to see a history log since revision 3:
user1@deby:~/project1/trunk$ svn log -r 3:HEAD
r3 | user1 | 2010-05-09 01:07:12 +0300 (Sun, 09 May 2010) | 1 line

Testing delete svn command
r4 | user1 | 2010-05-09 01:11:56 +0300 (Sun, 09 May 2010) | 1 line

Testing modifications

File defferences

Open readme.txt file and add world to the end. Now we can see a difference we made:
user1@deby:~/project1/trunk$ svn diff readme.txt
Index: readme.txt
--- readme.txt  (revision 4)
+++ readme.txt  (working copy)
@@ -1 +1 @@
+hello world
Read more about subversion here.

No comments :

Post a Comment