简体   繁体   中英

SVN: Ignore but NOT delete a folder

I have a junk folder, where my application puts temporary files. I don't want to commit them (surely), but the folder must exists or application will crash.

If I use standard TortoiseSVN ignore feature, it will add "svn:ignore junk_folder" property to parent folder, but it will also delete "junk_folder" which cannot happen.

If I revert only delete operation (did by TortoiseSVN) but leave adding "svn:ignore" property, this solution will fail. TortoiseSVN will report files inside "junk_folder" as non-versioned, which I want to avoid.

Is there any solution that would allow me to completely ignore particular folder in SVN (so no matter, what will be put in it, won't be reported as unversioned and won't be auto commited as well) without deleting it?

EDIT : I forgot to add that I'm talking about already versioned folder. It seems that, if you ignore (svn:ignore or proper option in TortoiseSVN) a folder that wasn't yet versioned (before first commit) then everything is OK. But, if you do this on the folder that already was in repository, TortoiseSVN marks it as deleted and deletes it from both repository (but not from Local Working Copy) upon next commit.

I believe you can just add an svn:ignore for "*" within that folder, instead of on "junk_folder" itself (in other words, ignore "junk_folder/*").

I don't know if TortoiseSVN has a button for that, but from the command line you can do it with the command:

svn propset svn:ignore "*" junk_folder

(at least I think that is the right syntax, off the top of my head. if someone thinks that is wrong, please correct me)

I use this for things like compiler intermediate output folders, and it has never deleted anything.

To re-test this, I found an unversioned directory in one of my working copies. I right clicked on the directory, and navigated to the "Add to ignore list" option. It expanded to the directory name. I selected the directory name and received a pop up message noting that it had been added to the ignore list. Checking the working copy status, the parent folder had a property only modification. No files were marked for deletion.

Ignoring Files And Directories

在此处输入图片说明

As a side note , you can also hide unversioned files when using "Check for Modifications" and Commit dialogs with a checkbox near the bottom of the dialog.

I am using Eclipse Subversive and Tortoise SVN.

My approach to this problem is to use the properties dialog from Tortoise (but I think Eclipse has the same feature)

If you right click on a folder in your working copy, eg 'tmp' or 'cache' etc you can simply add the 'svn:ignore' property and put a wild card in there. You need to use the advanced button to add it because its not the the quick list of properties to add.

I am developing websites mostly on Joomla, and regularly installers or other components leave files in places that I don't want in the repo. And as mentioned 'svn:ignore'ing these folders using the 'right click ignore' method means these folder are completely excluded from the repo which is not what you want - you want the contents of those folders excluded, or sometimes just files with a certain extension.

after getting much advice from stackoverflow I signed up today to just to answer this question so hope it helps someone - I tried to attach screen shot but not enough rep :(

What do you mean " If I use standard TortoiseSVN ignore feature, it will add svn:ignore junk_folder property to parent folder, but it will also delete junk_folder ... "?

Subversion does not delete a folder you ask it to ignore. In fact, that's the whole purpose of svn:ignore : To allow you to have a folder that's not in the repository without Subversion whining about it.

How is this junk_folder created? Is it by a script you use, or do you do it manually? Exactly when does it get deleted? Do you mean when you do a new checkout, junk_folder isn't there, or that TortoiseSVN deletes it as soon as you add the svn:ignore property on its parent directory?

If you need that folder permanently in your repository, but it must remain empty, you can add junk_folder to the repository, and then create a svn:ignore property that's set to * . That will ignore anything in the folder.

My suggestion is to make sure that whatever scripts need junk_folder create it if it doesn't exist, and not to add it to your repository. You can use this pre-commit hook to keep it out of your repository. That would be the best way to handle this. There's no reason why an empty directory named junk_folder should be in your repository.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM