Creating a repository
- mkdir svn-repos
- svnadmin create /cygdrive/c/svn-repos
- ls -a /cygdrive/c/svn-repos
Creating a project
- cd temp
- svn import -m "importing Snipe project" . file:///cygdrive/c/svn-repos/snipe/trunk
- import tells svn to import some files to repository
- -m to associate message to import
- . to import contents of current directory
- The final parameter is repo URL describing where we want to import the files
- file:// tells svn to look on local file system for the repo
Working with a project
Checkout
- mkdir svn_workspace; cd svn_workspace
- svn co file:///cygdrive/c/svn-repos/snipe/trunk snipe
- How to checkout to older version ?
- svn co -r 5 file:///cygdrive/c/svn-repos/snipe/trunk snipe-old5
Making changes
- vi day.txt
- svn status day.txt
- M indicates that the above file is modified
- svn diff day.txt
Index: day.txt
===================================================================
--- day.txt (revision 1)
+++ day.txt (working copy)
@@ -3,3 +3,5 @@
wednesday
thursday
friday
+saturday
+sunday
Adding files
- svn add mydir
Checkin
- svn commit -m "facliltating to work on weekends"
- svn log day.txt
------------------------------------------------------------------------
r2 | guruss1 | 2014-03-26 12:48:20 +0530 (Wed, 26 Mar 2014) | 1 line
facliltating to work on weekends
------------------------------------------------------------------------
r1 | guruss1 | 2014-03-26 12:23:27 +0530 (Wed, 26 Mar 2014) | 1 line
importing Snipe project
------------------------------------------------------------------------
- svn log --verbose day.txt or svn log -v day.txt
Setting up external editor to provide commit message
- export SVN_EDITOR=notepad
Mixed revision working copies
- svn log without any other arguments shows log for the current directory and any sub-directories
- if you run svn log immediately after commit, svn doesn't tell you about your change. We can see the change if run svn log day.txt
- To see the log message for directory, run svn update first
- svn update
Updating '.':
At revision 3.
How to check from where a working copy came from? svn info
- svn info snipe-old5
Path: snipe-old5
Working Copy Root Path: /cygdrive/c/svn_workspace/snipe-old5
URL: file:///cygdrive/c/svn-repos/snipe/trunk
Relative URL: ^/snipe/trunk
Repository Root: file:///cygdrive/c/svn-repos
Repository UUID: d231f21e-4492-4b58-bb57-dd135cc89b28
Revision: 5
Node Kind: directory
Schedule: normal
Last Changed Author: guruss1
Last Changed Rev: 5
Last Changed Date: 2014-03-26 14:24:06 +0530 (Wed, 26 Mar 2014)
Updating a workspace
- cd <workspace-root>; svn update
- How to update only a specific files or directories?
- svn update number.txt
- Update command output indicators
- A - added a file
- U - updated a out-of-date file
- D - removed a file
- G - A file was out-of-date in the workspace, which you had modified locally. SVN merged changes from repo with your local modifications
- C - A file was out-of-date in the workspace, hich you had modified locally. SVN tried to merge changes from repo with your local modifications, but got a conflict.
- U - Space followed by U, indicates changes to file properties, rather than file itself.
Properties
- Properties are metadata associated with file and directories. It is named using simple strings and can contain any content (including binary data)
- How to set property on a file?
- svn propset reviewed-by "Likith AN" number.txt
- svn status
M number.txt
? trunk
- svn ci -m "reviewer added"
- How to edit a property?
- svn propedit reviewed-by number.txt
- How to list all the properties for a file?
- svn proplist number.txt
- How to print current value of a property?
- svn propget reviewed-by number.txt
- How to delete a property?
- svn propdel description number.txt
Handling merge conflicts
Merging changes
- svn co file:///cygdrive/c/svn_repos/snipe/trunk snipe_advanced
- cd snipe; vi number.txt; svn commit -m "supporting more numbers"
- cd ../snipe_advanced/
- svn status -u
* 3 number.txt
Status against revision: 4
- The above command tells if any updates are available for snipe_advanced directory
- The '*' indicates the availability of update for number.txt, which is currently at revision 3.
- svn diff -rHEAD number.txt
- Check the difference between our version and the head revision in repo
- -rHEAD tells to compare the current version to head revision in repo. If we doesn't provide this option, then svn compares local copy against repo version that was checked out.
- svn update
Updating '.':
U number.txt
Updated to revision 4.
- The above command merge changes from repo. svn prints U next to number.txt to let us know that it has updated it and tells us that our working copy has been updated to revision 4
Conflict resolution
Scenario 1: When changes doesn't overlap
- cd ../snipe ; vi number.txt
- cd ../snipe_advanced/ ; vi number.txt; svn commit -m "making 7 important"
- cd ../snipe
- svn commit -m "emphasizing zero"
svn: E155011: Commit failed (details follow):
svn: E155011: File '/cygdrive/c/svn_workspace/snipe/number.txt' is out of date
svn: E160028: File '/snipe/trunk/number.txt' is out of date
- svn update
Updating '.':
G number.txt
Updated to revision 5.
- svn prints a G to tell us it has merged our changes with the repository version
- svn commit -m "emphasizing zero"
Scenario 2: When changes conflicts
- cd ../snipe_advanced/; vi number.txt; svn commit -m "kannada one"
- cd ../snipe; vi number.txt;
- svn commit -m "hindi one"
Sending number.txt
svn: E155011: Commit failed (details follow):
svn: E155011: File '/cygdrive/c/svn_workspace/snipe/number.txt' is out of date
svn: E160028: File '/snipe/trunk/number.txt' is out of date
- svn update
Updating '.':
C number.txt
Updated to revision 7.
Conflict discovered in file 'number.txt'.
Select: (p) postpone, (df) show diff, (e) edit file, (m) merge,
(mc) my side of conflict, (tc) their side of conflict,
(s) show all options: df
--- number.txt.r7 - THEIRS
+++ number.txt - MERGED
@@ -1,5 +1,9 @@
ZERO
+<<<<<<< .mine
+ek
+=======
ondu
+>>>>>>> .r7
two
three
four
Select: (p) postpone, (df) show diff, (e) edit file, (m) merge,
(r) mark resolved, (mc) my side of conflict,
(tc) their side of conflict, (s) show all options: p
- Find out who made change in version 7: svn log -r7 number.txt
- Resolve it manually
- svn resolved number.txt
- svn commit -m "one is hindi, two is kannada"