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?

kristian nissen
  • 2,809
  • 5
  • 44
  • 68
  • See this Q&A: http://stackoverflow.com/questions/69448/how-do-i-keep-resharper-files-out-of-svn – Fredrik Mörk Jun 04 '09 at 14:47
  • More like http://stackoverflow.com/questions/862950/subversion-prevent-local-modifications-to-one-file-from-being-committed – Aaron Digulla Jun 04 '09 at 14:59
  • Possible duplicates: http://stackoverflow.com/questions/940057/in-subversion-how-can-i-un-hijack-a-file http://stackoverflow.com/questions/714307/svn-ignoring-an-already-committed-file – TJR Jun 04 '09 at 15:07
  • 2
    7 years after this question, I am still looking for a working solution. Any luck finding anything? – Slav Apr 07 '16 at 14:35
  • @Slav If you are using TortoiseSVN you can use **changelist** and hit ignore-on-commit. – Lying_cat Sep 06 '18 at 05:37

6 Answers6

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.

NeilInglis
  • 3,431
  • 4
  • 30
  • 31
  • 5
    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 – kristian nissen Jun 04 '09 at 14:51
  • 1
    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. – Jeremy Jun 15 '09 at 22:00
  • 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. – alejandrob Aug 17 '16 at 17:10
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.

Community
  • 1
  • 1
Vargas
  • 2,125
  • 2
  • 33
  • 53
  • 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 – achecopar Apr 06 '17 at 17:28
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.

Ken
  • 2,092
  • 1
  • 19
  • 16
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

William Leara
  • 10,595
  • 4
  • 36
  • 58
  • 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... – kristian nissen Jun 08 '09 at 09:04
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' ./

Rap
  • 6,851
  • 3
  • 50
  • 88
  • 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. – kristian nissen Jun 08 '09 at 09:09
-1

svn propedit svn:ignore ./some_path

For details see this post.

NoahD
  • 8,092
  • 4
  • 27
  • 28