views:

2670

answers:

8

With TortoiseSVN, I can move a file into the ignore-on-commit changelist, so that when I commit a whole tree, changes to that file do not get committed.

Is there a way to do something like that using the svn command-line tool?

EDIT: Thanks for the suggestions to use svn:ignore, but that doesn't do quite what I was looking for.

svn:ignore affects things like svn add & import. It gives it a list of filename patterns to ignore.

I have a file that's already under source control, but I want to make temporary changes to that file that I don't want to be committed later on when I commit the whole source tree. I am making a lot of other changes and I could stick a note on my monitor telling me to revert that file before I commit the tree, but it would be nice if svn could automatically skip that file.

+11  A: 

svn:ignore is your answer.

Example:

$ svn propset svn:ignore -F .cvsignore .
property 'svn:ignore' set on '.'
Manuel Ferreria
Note, the above example shows how to use a previously-configured cvsignore file as input to your svnignore property.
Ben Hoffstein
Thanks for the clarification.
Manuel Ferreria
+1  A: 

Yes, you can use the svnignore property to accomplish this. For example:

svn propset svn:ignore config.php
Ben Hoffstein
+1  A: 
svn propset "svn:ignore" "*.xml" .

the *.xml is the pattern of files to ignore; you can use directory names here as well

Homes2001
+4  A: 

I don't believe there is a way to ignore a file in the repository. We often run into this with web.config and other configuration files.

Although not perfect, the solution I most often see and use is to have .default file and an nant task to create local copies.

For example, in the repo is a file called web.config.default that has default values. Then create a nant task that will rename all the web.config.default files to web.config that can then be customized to local values. This task should be called when a new working copy is retrieved or a build is run.

You'll also need to ignore the web.config file that is created so that it isn't committed to the repository.

Steven Lyons
+4  A: 

Check out changelists, which can provide you with an option to filter out files you have changed but do not want to commit. SVN will not automatically skip a file unless you tell it to - and the way you tell it that this file is somehow different to other files is to put it in a changelist.

It does require more work for you, and you can only apply the changelist to your working copy (obviously, imagine the chaos that could ensue if you could apply a 'never update' property to a revision!).

gbjbaanb
A: 

Try adding a matching pattern in your ~/.subversion/config file (or the Tortoise equiv whatever that might be)

jayrdub
+9  A: 

To handle this using the ignore-on-commit changelist from the command-line, try this:

svn changelist ignore-on-commit file-you-want-to-add

I just tried it myself, and it added it to the same ignore-on-commit changelist when I checked my commit list in TortoiseSVN, so presumably it's doing the same thing...

EDIT:

It would appear this does not mark the file as don't commit (it's probably a rule TortoiseSVN has), however, if your other files are in a changelist, adding '--changelist foo' to your svn commit would do the trick. I haven't found a way to exclude a changelist yet.

Joshua McKinnon
A: 

Conflicted files are not allowed to be committed. You can take advantage of this to keep your private changes out of the repository. This works best with a small number of files.

To get a conflict for a-file, your working copy (WC) does not have the up to date a-file from the repository, and that the a-file in your WC has changes that are in the same location as changes in the repository (changes that you didn't update to yet). If you don't want to wait for the conditions above you can create a conflict for a-file like this:
In working copy 1 (WC1), add a line of text to the top of a-file, such as "make a conflict here". Use the necessary syntax so that you don't break the repository. Commit a-file from WC1. In WC2, add a different line of text to the top of a-file, like "i want a conflict". Update from WC2, and now a-file should be in conflict.

phi