Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding a single file to a Subversion repository but not other files along the path

The context is that I have an on off-the-shelf CMS which I want to make customizations to; so I want to keep the files I modify under version control, but I don't see the need to put the whole file tree under version control.

My problem is that I need to add a file to be kept under version control which is located a few subdirectories down, but I don't want to add anything else to the repository asides from the file and its parent folders.

To illustrate, say I have the following file in my project:

project/folder1/folder2/file.txt

I want to add file.txt to the repository, and folder1 is under version control but folder2 is not. There are existing files in folder1 and folder2 which I do not want to all put under version control.

Doing an svn import folder1/folder2/file.txt doesn't seem to work, as then I need to check out the file, and even if I delete the local version first, SVN complains that its parent folder exist. I presume that this means that if I use the --force option this would just clobber the contents of these folders.

The problem with svn add folder1/folder2/file.txt is that it requires each parent folder to be in the repository already (I gather from the fact that it can't find the folder2/.svn/entries file), but only folder1 is in the repository. So I figured I could do svn add folder1/folder2 first. The problem is that this puts the entire contents of folder2 into the repository, which I don't want. It seems the solution would be to do svn add --depth=empty folder1/folder2 which just adds the folder and no contents, but the --depth option is a new feature in Subversion 1.5, whereas I'm using 1.4.2 and it would good to avoid upgrading at this point.

So I'm wondering if there is a way around the lack of a --depth option in older versions of Subversion? Or is there another way of solving this problem" I'm also wondering if perhaps the way I went about setting it up in the first place was not so helpful.

like image 835
nedned Avatar asked Oct 09 '09 05:10

nedned


People also ask

What is the best recommended way to add new file to svn repo?

right drag them to the new location inside the working copy. release the right mouse button. select Context Menu → SVN Add files to this WC. The files will then be copied to the working copy and added to version control.

Can multiple files be added in svn?

Edit These files exist in a directory tree so adding * for one directory will not work. @your edit: So then provide multiple paths to add like: svn add dir1/* dir2/* dir3/* or as many have mentioned grep the ouput of svn stat from the root and pipe it to cut or awk and then to add.

How do I checkout a specific file in svn?

svn” or “_svn” should now be present). Within the repository now, right click the single file that you wish to have checked out alone and select the “Update Item to revision” option. The single file can now be worked on and checked back into the repository.


1 Answers

You should add the folder with the option "--non-recursive":

svn add --non-recursive folder1/folder2
like image 66
tangens Avatar answered Oct 05 '22 22:10

tangens