Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add an existing folder with files to SVN?

Tags:

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.
like image 688
Siecje Avatar asked Mar 19 '13 20:03

Siecje


People also ask

How do you svn add all files?

To add an existing file to a Subversion repository and put it under revision control, change to the directory with its working copy and run the following command: svn add file… Similarly, to add a directory and all files that are in it, type: svn add directory…

How do I move a directory to a svn repository?

Moving files and folders select the files or directories you want to move. right drag them to the new location inside the working copy. release the right mouse button. in the popup menu select Context Menu → SVN Move versioned files here.

How do I copy a folder from one directory to another in svn?

The easiest way to copy files and folders from within a working copy is to use the right drag menu. When you right drag a file or folder from one working copy to another, or even within the same folder, a context menu appears when you release the mouse.


2 Answers

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
like image 161
qbolec Avatar answered Oct 08 '22 10:10

qbolec


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

like image 30
pmod Avatar answered Oct 08 '22 09:10

pmod