How to add an existing folder with files to SVN?
Solution 1:
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.).
- Create an empty folder in the repository
svn mkdir https://svn.host/existing_path/myNewApp
- Go to the parent directory of the project,
cd ~/local_dir
- 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. - You can see that
svn st
will now show all your files as?
, which means that they are not currently under revision control - Perform
svn add
on files you want to add to the repository, and add others tosvn:ignore
. You may find some useful options withsvn help add
, for example--parents
or--depth empty
, when you want selectively add only some files/folders. - Commit with
svn ci
Solution 2:
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:
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:
In Windows 7 I did this:
- Have you installed SVN and Tortoise SVN? If not, Google them and do so now.
- 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).
- Create a new folder to store your new repository. Call it the same name as your project title
- Right click the folder and choose Tortoise SVN -> Create Repository here
- Say yes to Create Folder Structure
- Click OK. You should see a new icon looking like a "wave" next to your new folder/repo
- Right Click the new repo and choose SVN Repo Browser
- Right click 'trunk'
- Choose ADD Folder... and point to your folder structure of your project in development.
- 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:
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.
- I have a project (Test-4.2.2) in my local. I want to upload/add it to an SVN repository.
- Using the TortoiseSVN repo-browser, I created an empty directory, "Test-4.2.2"
- In my local I renamed the existing "Test-4.2.2" directory to "Test-4.2.2.1" (temporary)
- Checkout the empty "Test-4.2.2" from SVN to your local
- Copy all the sub-directories under 4.2.2.1 to this checkout directory 4.2.2
- Now, right click "Test-4.2.2" and commit.
- Delete the temp folder, "Test-4.2.2.1"