Svn Setup of Existing Directory

How to add an existing folder with files to SVN?

Let's say I have code in the directory ~/local_dir/myNewApp, and I want to put it under 'https://svn.host/existing_path/myNewApp' (while being able to ignore some binaries, vendor libraries, etc.).

  1. Create an empty folder in the repository svn mkdir https://svn.host/existing_path/myNewApp
  2. Go to the parent directory of the project, cd ~/local_dir
  3. Check out the empty directory over your local folder. Don't be afraid - the files you have locally will not be deleted. svn co https://svn.host/existing_path/myNewApp. If your folder has a different name locally than in the repository, you must specify it as an additional argument.
  4. You can see that svn st will now show all your files as ?, which means that they are not currently under revision control
  5. Perform svn add on files you want to add to the repository, and add others to svn:ignore. You may find some useful options with svn help add, for example --parents or --depth empty, when you want selectively add only some files/folders.
  6. Commit with svn ci

Make an existing folder into a repository

There is a simple solution for checking in an existing directory structure:

  1. Open the repository browser of TortoiseSVN (or any other SVN client you prefer) and create a new directory for the project you want to check-in.
  2. Check-out this newly created empty directory from SVN somewhere
  3. Open the checked-out directory and move the contained hidden .svn directory into the root directory of your project. This enables the context menus from TortoiseSVN for all files and sub-folders.
  4. Add every file and folder you want to check-in (context menu command Add...)
  5. Execute SVN Commit... on the project root folder

Add files to an already setup svn repo

You can copy the directory into your checked-out copy of the repository, then right click on the file, go to TortoiseSVN, and select add. This will add the folder to your repo, then commit the change (right click and select SVN Commit), and you should be good.

If that isn't sufficient for your question, I apologize.

GotAmye,
As long as the remote server is housing a subversion repository, this should work. What is running on the remote server that makes you think there will be a problem?

SVN Setup Of Existing Directory

Yes, you have it exactly. Once your code has been added to the repository, you can get rid of or rename your original code directory. Then checkout the project from the repository into the same location as your previous code and continue working from there.

UPDATE

To make it so that your website is updated from the repository, you actually need two working directories, and a repository.

Repository: The repository stores the code and changesets, but isn't directly accessible as a file system. Keep a backup!.

Working directory 1: You develop and test your code from a working directory checked out from the repository. Commit changes back to the repository.

Working directory 2: Rename the code directory on your webserver. Checkout a copy of the code to your web server in its place. Technically it is now a working directory, since it contains the .svn metadata directories, though you won't usually make changes here.

Make changes to your code from your development working directory (1) and commit them back to the repository. When you are satisfied that they are working correctly and have been properly tested, on the web server's code copy (2) do svn update (or if you're using Tortoise SVN on the web server, do an update). This will synchronize the server code with the current development version.

Subversion will not automatically push updates to your web server. You will need to pull them in with an update when you need to. It is possible to use what's called a "post-commit hook" to cause Subversion to execute a script when commits are made, and that script could update or export code to your production web server. However, you would need to write the script and it's kind of an advanced usage of Subversion. I would recommend trying out the method I described with a working copy on the web server to get accustomed to the workflow befrore trying anything more complicated.

Addendum If you really want to do this (and I don't really recommend it unless you really test well) a very easy method would be to schedule a cron job that does svn update every couple of hours (or minutes) on your production site.

Don't forget that if you do happen to modify your code directly on the web server, you must commit it back to the repository from there, and do an update on your development working copy.



Related Topics



Leave a reply



Submit