SVN Commands
SVN Commands
I am trying to post some parts of that session over here. Hope that it will be useful for that guys
1. Help:
Before reading on, here is the most important command you’ll ever need when using
Subversion: svn help. The Subversion command-line client is self-documenting—at any time,.
$svn help
Will display all available subcommands in svn. A quick svn help SUBCOMMAND will describe the
Syntax:
ex: This copy contains the HEAD (latest revision) of the Subversion repository that you specify
Although the above example checks out the trunk directory, you can just as easily check out any
password <PASSWORD>
3. update: Your Working Copy
$ svn update
For each updated item a line will start with a character reporting the
A Added
D Deleted
U Updated
C Conflict
G Merged
$ svn status
If you run svn status at the top of your working copy with no arguments, it will detect all file and
‘ ‘ ## no modifications
A mydir/foo.h ## file is scheduled for addition, this is new file, not in the repos
$ svn diff
Output is displayed in unified diff format. That is, removed lines are prefaced with a – and added
Subversion reverts the file to its pre-modified state by overwriting it with the cached copy from
bar.c
Reverted ‘bar.c’
bar.c
7. resolved: Resolving Conflicts: Conflicts come when there is some changes at the same line in
We can predict conflict in files without updating it, just by using status command with -u switch
$svn status -u
$ svn update
C bar.h
This means that the changes from the repository overlapped with your own.
Status code ‘C’ during the update means that the file is in a state of conflict.
For every conflicted file, Subversion places three extra unversioned files in your working copy
bar.h.mine ##This is your file as it existed in your working copy before you updated your
bar.h.rOld ##This is the file that was the BASE revision before you updated your working copy.
$ cat bar.h
———————–
India
SriLanka
<<<<<<< .mine
USA
Canada
=======
UK
France
>>>>>>> .rN
Egypt
South Africa
———————–
The strings of ‘<<<’, ‘===’, and ‘>>>’ signs are conflict markers.
You want to ensure that those are removed from the file before your next commit.
The text between the first two sets of markers is composed of the changes you made in the
conflicting area:
<<<<<<< .mine
USA
Canada
=======
The text between the second and third sets of markers is the text from others commit:
=======
UK
France
>>>>>>> .rN
Merge the conflicted text by hand. Or remove your local changes by running:
$ svn revert bar.h // to throw away all of your local changes.
Once you’ve resolved the conflict, you need to let Subversion know by running svn resolved. This
removes the three temporary files and Subversion no longer considers the file to be in a state of
conflict.
Syntax:
ex:
Syntax:
List each TARGET file and the contents of each TARGET directory as
The default TARGET is ‘.’, meaning the repository URL of the current
working directory.
svn list is most useful if you want to see what files a repository has without downloading a
working copy:
10. add: Add files, directories, or symbolic links to your working copy and schedule them for
They will be uploaded and added to the repository on your next commit. If you add something
and change your mind before committing, you can unschedule the addition using svn revert.
Syntax:
ex:
A MyDir
A MyDir/a
A MyDir/b
11. lock: Lock working copy paths or URLs in the repository, so that no other user can commit
changes to them.
Syntax:
ex:
Syntax:
The default target is the path of your current directory. If no arguments are supplied, svn log
shows the log messages for all files and directories inside of (and including) the current working
ex:
You can see the log messages for all the paths that changed in your working copy by running svn
$svn log
Syntax:
ex:
‘config.php’ unlocked.
‘config.png’ unlocked’.
‘config.php’ unlocked
Syntax:
svn delete PATH…
ex:
Using svn to delete a file from your working copy only schedules it to be deleted. When you
D myfile
Deleting myfile
http://openappdotorg.googlecode.com/svn/trunk/config.php
Syntax:
Recursively commit a copy of PATH to URL. If PATH is omitted “.” is assumed. Parent directories
ex:
This imports the local directory myproj into the root of your repository:
Syntax:
svn export [-r REV] URL [PATH]
The first form exports a clean directory tree from the repository specified by URL, at revision REV
if it is given, otherwise at HEAD, into PATH. If PATH is omitted, the last component of the URL is
The second form exports a clean directory tree from the working copy specified by PATH1 into
PATH2. All local changes will be preserved, but files not under version control will not be copied.
ex:
Syntax:
ex:
Syntax:
Create a directory with a name given by the final component of the PATH or URL. A directory
specified by a working copy PATH is scheduled for addition in the working copy. A directory
ex:
A newdir
Syntax:
This command moves a file or directory in your working copy or in the repository.
ex:
A bar.c ##added
D foo.c ##deleted
Move a file in the repository (an immediate commit, so it requires a commit message):
http://openappdotorg.googlecode.com/svn/trunk/bar.c
20. blame: Show author and revision information in-line for the specified files or URLs.
Syntax:
Show author and revision information in-line for the specified files or URLs. Each line of text is
annotated at the beginning with the author (username) and the revision number for the last
Syntax:
Copy a file in a working copy or in the repository. SOURCE and DEST can each be either a
ex:
Copy an item within your working copy (just schedules the copy—nothing goes into the
A bar.txt
Copy an item in your working copy to a URL in the repository (an immediate commit, so you
Copy an item from the repository to your working copy (just schedules the copy—nothing goes