Subversion (SVN) -
SVN is a version control system. This means that it is easier for several users to work on and edit the same files because it enables tracking of changes over time. Often used in relation to web and programming projects, design documents and such. If you're working together in a group, you can keep all your files on a server with SVN. When someone edits a file you've downloaded a copy of, you can easily update it by checking which versions are out. It is then easier to avoid overwriting other changes.
In addition to keeping track of changes, version control allows for back-tracking. This means that if a set of files stop working, it is possible to revert to the last working set.
There are a lot of different systems for version control:
Creating a version control repository
To be able to use version control, we have to create a repository. If one doesn't already exist, we have to create one at NTNU's UNIX-servers (as an example). For logging in to one of them, you can use PuTTY, which is free software for connecting to servers. For example, login.stud.ntnu.no.
To create an SVN repository, you need a folder. By using svnadmin create path you'll change the folder to an SVN repository.
langemyh@caracal: ~/svn$ mkdir repos langemyh@caracal: ~/svn$ svnadmin create rep
Checkout
A checkout creates a working copy of the repository on your local drive. By adding options, you can choose which revision you want - but of course not the first time. All files and folders will be copied to a folder as specified. Below is an example where the checkout-folder is called svn.
langemyh@caracal: ~/svn$ mkdir svn langemyh@caracal: ~/svn$ svn checkout file:///home/homer/la/langemyh/svn/rep svn/ Checked out revision 0.
We have now created a repository, checked out the files there. So now we want to see how we can add files to the repository.
Add
You'll want to use the command add to add files. As an example, we'll add the file svn.html:
langemyh@caracal: ~/svn/svn$ svn help add add: Put files and directories under version control, scheduling them for addition to repository. They will be added in next commit. usage: add PATH... langemyh@caracal: ~/svn/svn$ svn add svn.html A svn.html
Commit
For adding files to the repository/server, you use the command commit, or check-in/ci/submit. Your working copy will then be written or merged into the repository.
langemyh@caracal: ~/svn/svn$ svn help commit commit (ci): Send changes from your working copy to the repository. usage: commit [PATH...] langemyh@caracal: ~/svn/svn$ svn commit svn.html Adding svn.html Transmitting file data . Committed revision 1.
When you commit, you will be prompted for a comment to accompany your check-in. Keep that comment short, but informative. It is then easier to decide which version to revert to if something stops working. The editor for that command will be pico, but you might want to change that. Here we change it to vim:
langemyh@caracal: ~/svn/svn$ EDITOR=vim; export $EDITOR; echo $EDITOR vim
Update
You can use the command update to download the latest version of a file/folder.
langemyh@caracal: ~/svn/svn$ svn help update update (up): Bring changes from the repository into the working copy. usage: update [PATH...] If no revision given, bring working copy up-to-date with HEAD rev. Else synchronize working copy to revision given by -r. For each updated item a line will start with a character reporting the action taken. These characters have the following meaning: A Added D Deleted U Updated C Conflict G Merged langemyh@caracal: ~/svn/svn$ svn update svn.html At revision 1.
Remove
Logically, the command remove is used to remove a file or folder from version control and the repository.
langemyh@caracal: ~/svn/svn$ svn help remove delete (del, remove, rm): Remove files and directories from version control. usage: 1. delete PATH... 2. delete URL... 1. Each item specified by a PATH is scheduled for deletion upon the next commit. Files, and directories that have not been committed, are immediately removed from the working copy. PATHs that are, or contain, unversioned or modified items will not be removed unless the --force option is given. 2. Each item specified by a URL is deleted from the repository via an immediate commit. langemyh@caracal: ~/svn/svn$ svn remove svn.html D svn.html
Status
Before commiting/updating your repository, it is often useful to check the status of the file. With this command you will get information concerning the version, if it is conflicting with another version and if it exists in the repository at all.
langemyh@caracal: ~/svn/svn$ svn help status status (stat, st): Print the status of working copy files and directories. usage: status [PATH...] With no args, print only locally modified items (no network access). With -u, add working revision and server out-of-date information. With -v, print full revision information on every item. The first six columns in the output are each one character wide: First column: Says if item was added, deleted, or otherwise changed ' ' no modifications 'A' Added 'C' Conflicted 'D' Deleted 'G' Merged 'I' Ignored 'M' Modified 'R' Replaced 'X' item is unversioned, but used by an externals definition '?' item is not under version control langemyh@caracal: ~/svn/svn$ svn status svn.html R svn.html
Diff
The command diff will give you all differences between your version of files and folders locally and the repository.
- + extra in your copy
- - extra on repository
langemyh@caracal: ~/svn/svn$ svn help diff diff (di): Display the differences between two paths. usage: 1. diff [-r N[:M]] [TARGET[@REV]...] 2. diff [-r N[:M]] --old=OLD-TGT[@OLDREV] [--new=NEW-TGT[@NEWREV]] \ [PATH...] 3. diff OLD-URL[@OLDREV] NEW-URL[@NEWREV] 1. Display the changes made to TARGETs as they are seen in REV between two revisions. TARGETs may be working copy paths or URLs. N defaults to BASE if any TARGET is a working copy path, otherwise it must be specified. M defaults to the current working version if any TARGET is a working copy path, otherwise it defaults to HEAD. 2. Display the differences between OLD-TGT as it was seen in OLDREV and NEW-TGT as it was seen in NEWREV. PATHs, if given, are relative to OLD-TGT and NEW-TGT and restrict the output to differences for those paths. OLD-TGT and NEW-TGT may be working copy paths or URL[@REV]. NEW-TGT defaults to OLD-TGT if not specified. -r N makes OLDREV default to N, -r N:M makes OLDREV default to N and NEWREV default to M. 3. Shorthand for 'svn diff --old=OLD-URL[@OLDREV] --new=NEW-URL[@NEWREV]' Use just 'svn diff' to display local modifications in a working copy. langemyh@caracal: ~/svn/svn$ svn diff svn.html Index: svn.html =================================================================== --- svn.html (revision 3) +++ svn.html (working copy) @@ -198,4 +198,14 @@ ...
Revert
And last, but not least, the command revert is used to revert to earlier versions of a file or folder. All changes to the local file will then be deleted.
langemyh@caracal: ~/svn/svn$ svn help revert revert: Restore pristine working copy file (undo most local edits). usage: revert PATH... Note: this subcommand does not require network access, and resolves any conflicted states. However, it does not restore removed directories. langemyh@caracal: ~/svn/svn$ svn revert svn.html Reverted 'svn.html'
More information
For more information on how to use SVN, see this page.
| Languages: | Comments: | 0 | Aid: | 542 | User rating: |
|
|
| Last updated: | 2007-07-31 | Author: | livermor | Read: | 170 times |