Quick Introduction to SVN commands

I will start with a quick overview of the commands you should know, and then I will demonstrate them via a transcript of some artificial work on an actual Subversion repository.

Commands

Transcript

What follows is an annotated transcript of a series of shell commands that I executed to demonstrate the commands above.

You should look carefully at the portion of the transcript where I attempt to do svn commit -m "Adding everyone to salutation.". That section illustrates a subversion conflict, shows the four files that are generated by the svn update that revealed the conflict, and illustrates how to use the svn resolved command to remove the conflict marking after one has fixed the problem.

pnkfelix% export REPOSITORY_ROOT=svn+ssh://pnkfx.org/Users/pnkfelix/SvnRoot/WorkLog/test
pnkfelix% svn co $REPOSITORY_ROOT test-1
Checked out revision 50.
pnkfelix% ls test-1
pnkfelix% ls -a test-1
.	..	.svn
pnkfelix% cd test-1
test-1% cat > file.txt
Hi there.  The first line.
This is the second line.
And a third line.


I will now switch to a tabular format, so that you can see how changes to two distinct checkouts (named test-1 and test-2) propagate up to the repository and down to the checkouts.

(I apologize for the width of the presentation. The most important thing to read is the sequence of shell commands, to see what messages Subversion delivers, and how one invokes commands to deal with updates and conflicts.)

repository file.txt test-1 file.txt test-2 file.txt shell commands
(nothing)
Hi there.  The first line.
This is the second line.
And a third line.
(nothing)
test-1% svn add file.txt 
A         file.txt
test-1% svn commit -m "Committing file to demonstrate svn commands." file.txt 
Adding         file.txt
Transmitting file data .
Committed revision 51.

Hi there.  The first line.
This is the second line.
And a third line.
test-1% cd ..
pnkfelix% svn co $REPOSITORY_ROOT test-2
A    test-2/file.txt
Checked out revision 51.
Hi there.  The first line.
This is the second line.
And a third line.
pnkfelix% ls test-1
file.txt
pnkfelix% ls test-2
file.txt
pnkfelix% ls -a test-1
.		..		.svn		file.txt
pnkfelix% ls -a test-1/.svn
.		entries		prop-base	text-base
..		format		props		tmp
pnkfelix% ls -a test-2
.		..		.svn		file.txt
pnkfelix% cd test-2
test-2% cat file.txt 
Hi there.  The first line.
This is the second line.
And a third line.
test-2% cat > file.txt
Hello there.  The first line.
This is the second line.
And a third line.
Hello there.  The first line.
This is the second line.
And a third line.
test-2% svn diff file.txt 
Index: file.txt
===================================================================
--- file.txt	(revision 51)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
-Hi there.  The first line.
+Hello there.  The first line.
 This is the second line.
 And a third line.
test-2% svn commit -m "Changed Hi to Hello in first line." file.txt
Sending        file.txt
Transmitting file data .
Committed revision 52.
Hello there.  The first line.
This is the second line.
And a third line.
test-2% cd ../test-1
test-1% ls
file.txt
test-1% cat file.txt 
Hi there.  The first line.
This is the second line.
And a third line.
test-1% svn up
U    file.txt
Updated to revision 52.
Hello there.  The first line.
This is the second line.
And a third line.
test-1% cat file.txt
Hello there.  The first line.
This is the second line.
And a third line.
test-1% cat > file.txt
Hello there.  The first line.
This is a second line.
And a third line.
Hello there.  The first line.
This is a second line.
And a third line.
test-1% cat file.txt 
Hello there.  The first line.
This is a second line.
And a third line.
test-1% svn diff
Index: file.txt
===================================================================
--- file.txt	(revision 52)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
 Hello there.  The first line.
-This is the second line.
+This is a second line.
 And a third line.
test-1% cd ../test-2
test-2% svn up
At revision 52.
test-2% svn status
test-2% cat > file.txt
Hello there.  The first line.
This is the second line.
And the third line.
Hello there.  The first line.
This is the second line.
And the third line.
test-2% svn diff
Index: file.txt
===================================================================
--- file.txt	(revision 52)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
 Hello there.  The first line.
 This is the second line.
-And a third line.
+And the third line.
test-2% svn commit -m "A small change to the third line." file.txt 
Sending        file.txt
Transmitting file data .
Committed revision 53.
Hello there.  The first line.
This is the second line.
And the third line.
test-2% cd ../test-1
test-1% svn diff
Index: file.txt
===================================================================
--- file.txt	(revision 52)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
 Hello there.  The first line.
-This is the second line.
+This is a second line.
 And a third line.
test-1% svn status
M      file.txt
test-1% svn up
G    file.txt
Updated to revision 53.
Hello there.  The first line.
This is a second line.
And the third line.
test-1% svn diff
Index: file.txt
===================================================================
--- file.txt	(revision 53)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
 Hello there.  The first line.
-This is the second line.
+This is a second line.
 And the third line.
test-1% cat file.txt
Hello there.  The first line.
This is a second line.
And the third line.
test-1% svn commit -m "a small change to the second line." file.txt 
Sending        file.txt
Transmitting file data .
Committed revision 54.
Hello there.  The first line.
This is a second line.
And the third line.
test-1% cat > file.txt 
Hello there.  Great first line.
This is a second line.
And the third line.
Hello there.  Great first line.
This is a second line.
And the third line.
test-1% svn diff file.txt 
Index: file.txt
===================================================================
--- file.txt	(revision 54)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
-Hello there.  The first line.
+Hello there.  Great first line.
 This is a second line.
 And the third line.
test-1% cd ../test-2
test-2% svn status
test-2% svn up
U    file.txt
Updated to revision 54.
test-2% cat file.txt 
Hello there.  The first line.
This is a second line.
And the third line.
test-2% cat > file.txt 
Hello there everyone.  The first line.
This is a second line.
And the third line.
Hello there everyone.  The first line.
This is a second line.
And the third line.
test-2% svn diff
Index: file.txt
===================================================================
--- file.txt	(revision 54)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
-Hello there.  The first line.
+Hello there everyone.  The first line.
 This is a second line.
 And the third line.
test-2% cd ../test-1
test-1% svn diff
Index: file.txt
===================================================================
--- file.txt	(revision 54)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
-Hello there.  The first line.
+Hello there.  Great first line.
 This is a second line.
 And the third line.
test-1% svn commit -m "deliberate changing first line to conflict w/ test-2"
Sending        file.txt
Transmitting file data .
Committed revision 55.
Hello there.  Great first line.
This is a second line.
And the third line.
test-1% cd ../test-2
test-2% ls
file.txt
test-2% cat file.txt 
Hello there everyone.  The first line.
This is a second line.
And the third line.
test-2% svn diff
Index: file.txt
===================================================================
--- file.txt	(revision 54)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
-Hello there.  The first line.
+Hello there everyone.  The first line.
 This is a second line.
 And the third line.
test-2% svn commit -m "Adding everyone to salutation." 
Sending        file.txt
Transmitting file data .svn: Commit failed (details follow):
svn: Out of date: '/test/file.txt' in transaction '1l'
test-2% ls
file.txt
test-2% svn up
C    file.txt
Updated to revision 55.
<<<<<<< .mine
Hello there everyone.  The first line.
=======
Hello there.  Great first line.
>>>>>>> .r55
This is a second line.
And the third line.
test-2% ls
file.txt	file.txt.mine	file.txt.r54	file.txt.r55
test-2% cat file.txt.mine 
Hello there everyone.  The first line.
This is a second line.
And the third line.
test-2% cat file.txt.r54 
Hello there.  The first line.
This is a second line.
And the third line.
test-2% cat file.txt.r55 
Hello there.  Great first line.
This is a second line.
And the third line.
test-2% cat file.txt
<<<<<<< .mine
Hello there everyone.  The first line.
=======
Hello there.  Great first line.
>>>>>>> .r55
This is a second line.
And the third line.
test-2% cat > file.txt
Hello there everyone.  Great first line.
This is a second line.
And the third line.
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-2% cat file.txt
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-2% ls
file.txt	file.txt.mine	file.txt.r54	file.txt.r55
test-2% svn status
?      file.txt.mine
?      file.txt.r54
?      file.txt.r55
C      file.txt
test-2% svn commit -m "Adding everyone to salutation." 
svn: Commit failed (details follow):
svn: Aborting commit: '/Users/pnkfelix/test-2/file.txt' remains in conflict
test-2% ls
file.txt	file.txt.mine	file.txt.r54	file.txt.r55
test-2% svn status
?      file.txt.mine
?      file.txt.r54
?      file.txt.r55
C      file.txt
test-2% svn resolved file.txt
Resolved conflicted state of 'file.txt'
test-2% ls
file.txt
test-2% svn commit -m "Adding everyone to salutation." 
Sending        file.txt
Transmitting file data .
Committed revision 56.
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-2% svn status
test-2% cd ../test-1
test-1% svn status
test-1% svn up
U    file.txt
Updated to revision 56.
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-1% ls
file.txt
test-1% cat file.txt 
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-1% cat > file.txt
Whoops I'm trampling
all over the file
whhooaooaoaaoaoaaaa
Whoops I'm trampling
all over the file
whhooaooaoaaoaoaaaa
test-1% cat file.txt 
Whoops I'm trampling
all over the file
whhooaooaoaaoaoaaaa
test-1% svn diff
Index: file.txt
===================================================================
--- file.txt	(revision 56)
+++ file.txt	(working copy)
@@ -1,3 +1,3 @@
-Hello there everyone.  Great first line.
-This is a second line.
-And the third line.
+Whoops I'm trampling
+all over the file
+whhooaooaoaaoaoaaaa
test-1% svn revert file.txt 
Reverted 'file.txt'
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-1% cat file.txt 
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-1% rm file.txt 
(nothing)
test-1% svn status
!      file.txt
test-1% svn revert file.txt
Reverted 'file.txt'
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-1% svn status
test-1% cat file.txt 
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-1% ls
file.txt
test-1% svn rm file.txt
D         file.txt
(nothing)
test-1% ls
test-1% svn status
D      file.txt
test-1% cd ../test-2
test-2% svn status
test-2% svn up
At revision 56.
test-2% ls
file.txt
test-2% cat file.txt 
Hello there everyone.  Great first line.
This is a second line.
And the third line.
test-2% cd ../test-1
test-1% svn status
D      file.txt
test-1% svn commit -m "show that svn rm needs to be committed."
Deleting       file.txt

Committed revision 57.
(nothing)
test-1% svn status
test-1% cd ../test-2
test-2% ls
file.txt
test-2% svn status
test-2% svn up
D    file.txt
Updated to revision 57.
(nothing)
test-2% svn status
test-2% ls
test-2% 



Felix S Klock II