Subversion
- Apache-style license
- Bookkeeping subdirectory: .svn for each directory
Editing files
- After checking out files, commands can be run in any working directory with an .svn subdirectory
Checkout a file
svn <checkout,co> <svnroot-url>/<dir-name>/trunk <working-dir>
- When a directory is checked out from a repository, it will be created on the local drive at the current or specified location and does not have to exist ahead of time.
# Checkout to the current directory. cd /home/myname/wp svn checkout http://core.svn.wordpress.org/trunk # Destination: /home/myname/wp/trunk cd /home/myname/wp svn checkout http://core.svn.wordpress.org/trunk/wp-admin # Destination: /home/myname/wp/wp-admin
# Checkout to the specified directory (doesn't matter if it already exists). svn checkout http://core.svn.wordpress.org/trunk /home/myname/wp/trunk # Destination: /home/myname/wp/trunk
Export a file
- Get an unversioned copy of the file (no .svn subdirectories)
svn <export> <svnroot-url>/<dir-name>/trunk <working-dir>
- When a directory is exported from a repository, it will be created on the local drive at the current or specified location and does not have to exist ahead of time.
# Export to the current directory. cd /home/myname/wp svn export http://core.svn.wordpress.org/trunk # Destination: /home/myname/wp/trunk
# Export to the specified directory, which must not already exist. svn export http://core.svn.wordpress.org/trunk /home/myname/wp/trunk # Destination: /home/myname/wp/trunk # Use the --force option if the destination directory already exists. svn export --force http://core.svn.wordpress.org/trunk /home/myname/wp/trunk
Identify which working files have changed
cd <working-dir> svn <status,stat,st> [<file>]
- See which working files have changed since the last time they were checked out
- ?: Item is not under version control
- Not affected by the timestamp (if a file has been touched but the contents are not changed, then the file has not changed)
Show all changes to working files
cd <working-dir> svn <diff,di> [<file>] svn <diff,di> -r <revision1>:<revision2> [<file>]
- See how a working file has changed since it was checked out (will diff all changed files by default)
Check-in a file
cd <working-dir> svn <commit,ci> [-m "comment"] [<file>]
- Check-in working files that have changed (will check-in all such files by default)
- Fails if a file is "out-of-date", in which case an update should be done first)
Update the working files
cd <working-dir> svn <update,up> [<file>]
- Re-checkout the files
- Automatically attempts to merge changes if needed
svn <update,up> -r <rev> # Update to a specific revision number
Abandon changes to working files
cd <working-dir> svn [-R] revert [<file>] # -R: Recursively
- Re-checkout the files, overwriting any working files that have been changed
Show the history log
cd <working-dir> svn log [<file>]
Resolving conflicts
- There are two cases where a conflict may arise (which Subversion may or may not be able to resolve automatically):
- When you check-in a file (if someone else checked-in the file after you last checked it out)
- When you update a file (if you had made changes to your working copy)
Cleaning up temporary files
svn resolved <file>
- After a conflict has been resolved by hand
Modifying the repository
Create a directory
svn mkdir <dir>
- Add a directory to the repository
- Must be followed by a commit
- Creates the working copy and schedules the dir for addition to the repository (does not commit it)
- All parent directories must already exist
Add a file
svn add <file, dir> [--non-recursive,-N]
- Add to the repository
- Must be followed by a commit
- Schedules the file or dir for addition to the repository (does not commit it)
- By default, recursively adds the contents of a directory
Delete a file
svn <delete,del,remove,rm> <file, dir>
- Delete from the repository
- Must be followed by a commit
- Deletes the working copy and schedules the file or dir for deletion from the repository (does not commit the deletion)
Copy a file
svn <copy,cp> <src-file> <dest-file>
- Add a copy of a file to the repository
- Must be followed by a commit
- Copies the working file and schedules the new copy for addition to the repository (does not commit it)
- Copies the history (when committed)
Move a file
svn <move,mv,rename,ren> <src-file> <dest-file>
- Move a file in the repository
- Must be followed by a commit
- Moves the working file and schedules the file to be moved in the repository (does not commit the move)
- Retains the history (when committed)
Administrative commands
Create a repository
svnadmin create <svnroot-path>
Import a project into Subversion
Directory structure: <working-dir>/branches <working-dir>/tags <working-dir>/trunk/<files>
svn import <working-dir> <svnroot-url>/dir-name -m "<comment>"
Changes from CVS
- Renamed / copied / moved / removed files are versioned
- Directories and renames are versioned
- Commits are atomic; a failed commit does not result in corrupted files
- Branching and tagging are inexpensive operations
- Costs are proportional to change size, not project size
- Symbolic links are versioned in Unix
- Efficient versioning of binary files
- Files are organized as a set of directories, rather than a set of projects
Resources
- Subversion
- Version Control with Subversion - user guide
Sources
- http://subversion.tigris.org
- http://svnbook.red-bean.com - Version Control with Subversion
Parent URL:
category/data