How to add an existing folder with files to SVN?

Svn

Svn Problem Overview


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.

Svn Solutions


Solution 1 - 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

Solution 2 - Svn

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

Solution 3 - Svn

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

Solution 4 - Svn

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!

Solution 5 - Svn

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"

Solution 6 - Svn

3 Steps:

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

enter image description here

Solution 7 - Svn

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

svn add * --force

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSiecjeView Question on Stackoverflow
Solution 1 - SvnqbolecView Answer on Stackoverflow
Solution 2 - SvnpmodView Answer on Stackoverflow
Solution 3 - SvnvapcguyView Answer on Stackoverflow
Solution 4 - SvnFandango68View Answer on Stackoverflow
Solution 5 - SvnPurushothamanView Answer on Stackoverflow
Solution 6 - SvnArindam RoychowdhuryView Answer on Stackoverflow
Solution 7 - SvnParthiban SoundramView Answer on Stackoverflow