Friday, April 16, 2010

Using Subversion

Creating a repository
  • Create a new repository using visualsvn server

  • In windows explorer, right click on the root directory of items you want to add to source control and select TortoiseSVN > Import.Type the path to parent folder to create in your repository e.g. file:///C:/svn/myrepository/myfolder [don't specify the repository root path e.g. svn/myrepository]. Click on OK. This will add all files and subfolders under that folder to source control.
  • Right click on the folder again and click on SVN Checkout. Note the repository URL and checkout directory and amend as appropriate.
  • Right click on the folder and select SVN Commit

  • To add only selected files or folders, in windows explorer, from any directory, right click and select TortoiseSVN > Repo-browser. Type the URL of the repository just created.
  • Create the directory structure you want for your repository structure. Right-click in the left pane of the repository browser and select Create folder as appropriate.
  • Click on OK to close the repository browser.
  • Right click on the folder to use as the working directory and select SVN Checkout.
  • Set the repository URL e.g. file:///C:/svn/myrepository/myfolder and the checkout directory and click on OK
  • Accept any warning message that the target folder is not empty. Already existing files in the folder won't be deleted
  • To add files to source control, right click on the file and select TortoiseSVN > Add. Click on OK to mark the file for adding to source control.
  • When finished adding files, right click on the working folder and select SVN Commit. Click on OK to add the files to source control.
  • Items are now under version control

Daily use
  • To check in items, right click and select SVN Commit
  • To check out, no special action is needed. SVN by default uses an update-and-merge technique rather than lock-update-check-in, so that multiple people can update the same file at the same time. If you require to lock the file so that you are the only one who can modify it, right click and select TortoiseSVN > Get lock. Use TortoiseSVN > Release lock when finished.
  • To get latest, right click and select SVN update
  • To remove a file from version control, shift+right click on the file while viewing it from the right hand pane of windows explorer and choose the TortoiseSVN > Delete (keep local) menu. This will mark it for deletion from svn but keep the local copy. Right click on the file and select SVN Commit to effect the change. The normal TortoiseSVN > Delete command will immediately delete a file from the working folder. For a folder, it's marked for deletion and actually deleted when you commit. You can get a file back by browsing the repository and copying it from a previous revision, before it was deleted. Use TortoiseSVN > Revert to unmark an item previously marked for deletion.
  • To remove a folder from version control, right-drag the working copy onto itself. Windows explorer doesn't allow dragging items onto themselves in the same window though, so you must either use a second explorer window or drag onto the tree view. On the pop-up menu provided select SVN Export to here and accept to unversion the folder.
  • To export a folder, such that a copy is made to a different location without the .svn directories, right click on the folder and select TortoiseSVN > Export.
  • To create a tag or branch, right click on the folder, select TortoiseSVN > Branch/tag and in the To path: section, enter the path of the new branch/tag e.g. /tags/version2.2. The base directory e.g. tags in this case, needs to exist already.

Right-drag
In Windows explorer, it is possible to move/copy files not only by dragging them with the left mouse button, but also with the right mouse button. The difference is that the left-drag executes the operation immediately, and the right-drag will first show you a context menu where you can choose the operation. TortoiseSVN adds some of its commands to that right-drag context menu.

To add the files/folders to the working copy, right-drag unversioned files/folders on to a versioned folder and select SVN Add files to this WC.

To export items, right-drag versioned files/folders from your working copy to an unversioned folder and select one of these two commands
  • SVN Export to here: exports the dragged files/folders to the target location, i.e. creates a copy without the .svn folders
  • SVN Export all to here: exports the dragged files/folders to the target location, including unversioned files.

To move and copy your files and folders around in your working copy, right-drag files/folders inside your working copy and select one of these four commands
  • SVN Move versioned files here: moves the files to the drop location. If a file already exists, it will ask you what to do (rename the file, overwrite it or cancel).
  • SVN Move and rename versioned files here: the same as 'SVN Move versioned files here', except that it will ask for a new name for every dropped file.
  • SVN Copy versioned files here: the same as 'SVN Move versioned files here' but it leaves the original file, i.e. the file is copied not moved
  • SVN Copy and rename versioned files here: the same as 'SVN Move and rename versioned files here' but it leaves the original file, i.e. the files are copied not moved

No comments:

Post a Comment