[svn] How to add an existing folder with files to SVN?

How do you add a folder without version control to a specific SVN location? I often start writing code and only after I have a few folders containing code files do I add it to SVN.

What I usually do is:

  1. svn co the parent directory where I want to make a new folder to store my code.
  2. svn mkdir to make the directory I want to put my code in.
  3. Copy and paste my code over.
  4. svn commit.
  5. Delete my current working code directory.
  6. Re-create my working code directory using svn co.

This question is related to svn

The answer is


If I correctly understood your use case, I suggest to try using svn add to put the new folder under version, see here. The following will add the new folder with files recursively under version control (if you are inside valid working copy):

svn add new_folder
svn commit -m "Add New folder to the project"

If you are not in a working copy, create it with svn checkout, copy new_folder there and do the above steps.

OR

Try svn import, see here; the following will create a new folder and upload files to the repository:

svn import -m "Import new folder to the project" new_folder \
        http://SVN_REPO/repos/trunk/new_folder

Also note that:

After importing data, note that the original tree is not under version control. To start working, you still need to svn checkout a fresh working copy of the tree


If the intention is adding the local/working copy to SVN, I used to do it the following way.

Note: I use the TortoiseSVN client and these steps assume that you already have the TortoiseSVN client installed.

  1. I have a project (Test-4.2.2) in my local. I want to upload/add it to an SVN repository.
  2. Using the TortoiseSVN repo-browser, I created an empty directory, "Test-4.2.2"
  3. In my local I renamed the existing "Test-4.2.2" directory to "Test-4.2.2.1" (temporary)
  4. Checkout the empty "Test-4.2.2" from SVN to your local
  5. Copy all the sub-directories under 4.2.2.1 to this checkout directory 4.2.2
  6. Now, right click "Test-4.2.2" and commit.
  7. Delete the temp folder, "Test-4.2.2.1"

In Windows 7 I did this:

  1. Have you installed SVN and Tortoise SVN? If not, Google them and do so now.
  2. Go to your SVN folder where you may have other repos (short for repository) (or if you're creating one from scratch, choose a location C drive, D drive, etc or network path).
  3. Create a new folder to store your new repository. Call it the same name as your project title
  4. Right click the folder and choose Tortoise SVN -> Create Repository here
  5. Say yes to Create Folder Structure
  6. Click OK. You should see a new icon looking like a "wave" next to your new folder/repo
  7. Right Click the new repo and choose SVN Repo Browser
  8. Right click 'trunk'
  9. Choose ADD Folder... and point to your folder structure of your project in development.
  10. Click OK and SVN will ADD your folder structure in. Be patient! It looks like SVN has crashed/frozen. Don't worry. It's doing its work.

Done!


Let's try.. It is working for me..

svn add * --force

3 Steps:

  • Open "Repo Browser" (Use Link of yr parent folder) .
  • Right click Choose "Add Folder".
  • Browse to your folder.

enter image description here


I don't use commands. You should be able to do this using the GUI:

  • Right-click an empty space in your My Documents folder, select TortoiseSVN > Repo-browser.
  • Enter http://subversion... (your URL path to your Subversion server/directory you will save to) as your path and select OK
  • Right-click the root directory in Repo and select Add folder. Give it the name of your project and create it.
  • Right-click the project folder in the Repo-browser and select Checkout. The Checkout directory will be your Visual Studio\Projects\{your project} folder. Select OK.
  • You will receive a warning that the folder is not empty. Say Yes to checkout/export to that folder - it will not overwrite your project files.
  • Open your project folder. You will see question marks on folders that are associated with your VS project that have not yet been added to Subversion. Select those folders using Ctrl + Click, then right-click one of the selected items and select TortoiseSVN > Add
  • Select OK on the prompt
  • Your files should add. Select OK on the Add Finished! dialog
  • Right-click in an empty area of the folder and select Refresh. You’ll see “+” icons on the folders/files, now
  • Right-click an empty area in the folder once again and select SVN Commit
  • Add a message regarding what you are committing and click OK