19

how can I ignore files from my svn repo without deleting them as well?

When I work on existing projects I often have to setup a local version of the project and using my local database as well. With drupal for instance, I checkout the svn repo, change the settings.php file to match my local database, but now I have to make sure I do not commit the settings file again.

Is there any clever svn command that will fix this?

5

6 Answers 6

7

From the SVN Help:

I have a file in my project that every developer must change, but I don't want those local mods to ever be committed. How can I make 'svn commit' ignore the file?**

The answer is: don't put that file under version control. Instead, put a template of the file under version control, something like "file.tmpl".

Then, after the initial 'svn checkout', have your users (or your build system) do a normal OS copy of the template to the proper filename, and have users customize the copy. The file is unversioned, so it will never be committed. And if you wish, you can add the file to its parent directory's svn:ignore property, so it doesn't show up as '?' in the 'svn status' command.

Sign up to request clarification or add additional context in comments.

3 Comments

yes that would fix the problem, but the settings file is already under svn control, and I don't want to change that since I would have to change it on the production environment as well which I can't
the production file shouldn't be in source control at all if it contains connection string information for the database. much safer is to have a symlink to the file (in a more secure location than the source repository) created by your build/deploy process.
Please bear in mind that "should" is a verb that "should" apply only in unhumanly perfect worlds. The question was regarding how to actually ignore-on-commit instead of just ignoring (thus physically deleting) working copy files. BINs can be ignored and deleted, but conn files cannot be deleted but have to be ignored during commits.
1

Create a version of the file called ".template" and version control that. When you checkout rename and edit as you need. Then use the svn propedit svn:ignore to ignore the copy.

Comments

1

A possible solution would be to use changelists. You can group the files that you are changing into changelists, and then when you svn commit, you specify the changelist -- files not in the changelist are not affected.

create changelist
svn changelist math-fixes integer.c mathops.c

commit only files in changelist
svn ci -m "Fix a bug." --changelist math-fixes

1 Comment

This sounds like a lot of work, I don't want to specify files I have changed, rather files that shouldn't be committed, perhaps I understand you wrong...
1

This answer talks about creating a changelist named ignore-on-commit with your template file, it will only work if you are using TortoiseSVN.

But then, again, this is a per-user setting.

1 Comment

It also talks about "Create a pre-commit hook script that reject the commit when a specific property is being added. You can then add this property to files in the working copy to prevent commits", in case you don´t use Tortoise SVN
0

The easiest way is to go to any directory that contains your config file and set a property on it:

svn:ignore settings.php

It will stay as-is through all commits and updates. You command might look like this:

$ svn propset svn:ignore 'settings.php' ./

1 Comment

I just tested this. I did a checkout, sat up an svn ignore on a file using svn propset svn:ignore 'readme' ./ and then did a commit, but the readme file is still commited when it's changed.
-1

svn propedit svn:ignore ./some_path

For details see this post.

3 Comments

I have tried this, but the settings file will still be commited
Yes, this ignores a local-only file but does nothing to prevent tracking of a file that was already in the repo.
The OP has already stated that he doesn't want to delete the file from the repo. svn:ignore does nothing if the file still exists in the repo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.