These are some basic subversion commands used in day to day operations, they are meant to be used on the command line client, but the basic concept is the same on the
GUIs. The commands are meant to be given in one line. The
# means you are logged in as ROOT (or other user with
RW access to the repository) and the $ means a regular user.
Creating a new repository
# svnadmin create /Path/to/repositoryInitial import of files In your workstation, change the current
dir to the folder in which the files are located
$ svn import ./projectFolder/trunk/ https://www.myServerURL.com/repositoty/project/trunk/ -m "Initial import"Checking out a project to the workstationAfter the initial import, your source folder isn't yet a 'working copy'. You have to check out a fresh copy from the repository in order to use subversion commands on it.
$ svn co https://www.myServerURL.com/repositoty/project/trunk/ project
This will create a new folder 'project' in your current working
dir with the project files. If you want, you can rename this folder normally, but to rename anything inside it, you must use subversion commands so the system is aware of your modifications. When you checkout a project, the
SVN client creates a hidden folder
'.svn' inside each directory of the project. This folder contains files used by Subversion to signal that this is a 'working copy' of some project under version control.
Sending changes to the serverIn the directory where the modified files are located
$ svn commit -m "New method to count the weight of hypos in the Windows version"
Checking the revision logFrom your project folder
$ svn logTo see the log of a project that is not in your workstation:
$ svn log https://www.myServerURL.com/repositoty/project/trunk/Updating your local copy with the latest version on the serverFrom your project folder
$ svn update
This will bring your copy up to date with the latest version available.
Keep an eye on the letters that appear next to the name of the downloaded files:
- A = Added. File added
- G = Merged. Changes on the file on the server where added to your changes
- C = Conflict. Some changes you made conflict with changes on the server.
- U = Updated. Arquivo foi atualizado.
Updating a file (our the whole copy) to an older revisionFrom your project folder
$ svn update -r 999 fileName
999 is the
revision number. To update the whole working copy:
$ svn update -r 999Deleting and moving files and directoriesFrom your project folder
Delete:
$ svn rm fileName
Rename:
$ svn mv OLDfileName NEWfileName
This will rename the file. To move it, add the destination directory name before the destination file name.
$ svn mv OLDfileName ../OtherDir/NEWfileNameThe
SVN command line client can't move more than on file at a time.
To do that you can use the shell (bash)
$ for I in *.txt; do svn mv $I ./newFolder; done
This will move all .
txt files from the current folder to ./
newFolderCreate a folder
$ svn mkdir folderName
The rm,
mv and
mkdir commands affect only your working copy.
To apply them to the server, execute a
'commit'.If you want to execute them directly on the server, give the full URL to the file on the command line
(
eg. https://www.myServerURL.com/repositoty/project/trunk/fileName)Creating a TAG (to flag a release, for example)
$ svn copy https://www.myServerURL.com/repositoty/project/trunk/ https://www.myServerURL.com/repositoty/project//tags/1.0.42 -m "New version 1.0.42"
Listing project files and tagsListing files in the 'trunk'
$ svn list https://www.myServerURL.com/repositoty/project/trunk/Listing existing tags
$ svn list https://www.myServerURL.com/repositoty/project/tags/Checking out a tag
$
svn co https://www.myServerURL.com/repositoty/project/tags/1.0.42
Checking the state of the working copyThe '
svn status' command allows us to see which files where modified locally and/or in the server and thus make our copy outdated.
Checking for files modified locally
$ svn status
or
$ svn status fileName
Checking for files modified on the server
$ svn status -u
Files preceded by a
* where modified on the server. Use '
svn diff' with the full URL to see the changes.
$ svn diff https://www.myServerURL.com/repositoty/project/trunk/fileNameCreating an alias to an external project
We can create an 'alias' pointing to a folder in another project within our current project.
This is done using the '
svn:externals' propriety.
From your project folder:
$ svn propset svn:externals 'externalLib https://www.myServerURL.com/repositoty/OtherProject/trunk/libs/' myProjectObs: The 'libs' folder can't already exist in the '
myProject' or the process won't work. It will be retrieved from the trunk of the '
OtherProject'
To edit a
propriety value, use the command ‘
propedit’
$ svn propedit svn:externals myProjectList all currently set proprieties in a project
$ svn proplist dpzThe MERGE commandThis command compares 2 revisions of the repository and applies (merges) the differences between them in a
local copy.
From your project folder:
$ svn merge -r 700:751 https://www.myServerURL.com/repositoty/Project/trunk
This will retrieve all the changes happened between versions 700 e 751 in our project TRUNK and apply it in our ‘
working copy’ in the current directory (that can be a branch).
The command will produce a list of the modified files. You should check the files, accept the changes and commit (or revert).
$ svn ci -m 'merge of r 700:751 from trunk to release branch'You can get more
detailed info in the chapter 4 of the '
Version control with Subversion' book:
http://svnbook.red-bean.com/nightly/en/svn.branchmerge.html