54

Is it possible to ignore changes to a file in subversion locally on one client only, without propagating the ignore to the whole repository?

The particular problem I'm dealing with is that I've checked out a project and modified a bunch of files including the Makefile, which is already part of the repository. Now the environment I'm working on is different from the rest of the group, and I want the changes to the Makefiles to remain local on my machine and not be committed.

However, I don't want to set svn:ignore because that I believe would commit the ignore to the repository, while it is important to keep the make file there.

Cajunluke
  • 3,103
  • 28
  • 28
fuad
  • 4,265
  • 9
  • 34
  • 32
  • 4
    Fundamentally, I think you're trying to solve the wrong problem. Why not modify your Makefiles to work properly in both environments? – Nicholas Knight May 22 '09 at 03:51
  • 22
    Nicholas, even if fuad is not using the best approach to his problem, I'm pretty sure there are legitimate reasons to create ignores that apply only to your working copy. – allyourcode Jul 02 '09 at 19:58
  • 7
    I agree with allyourcode. A developer (user of svn) might not have the privilege or desire to change fundamental principles. I also would like a solution to this problem. We have environment property files checked in to our repo. When I change these locally, I have to manually uncheck them when I do checkins. It's only a matter of time until I forget to uncheck them. I would agree that these files should NOT be in our repo, but I don't have authority to make that decision, so I really need a workaround. – andersonbd1 Aug 14 '09 at 12:57

4 Answers4

42

As with many aspects of svn, tortoise makes it really easy. In fact, I believe tortoise actually adds features by using existing svn features in a systematic way. I realize this answer is windows only, then, but perhaps some people out there are like me and still use windows. In the "Check for Modifications" popup simply right click your files and select "Move to Changelist"->"ignore-on-commit". Now when you checkin using tortoise, it'll segment your changes into the various change lists, so at least you can visually tell what you want to commit and what you don't want to commit.

andersonbd1
  • 5,266
  • 14
  • 44
  • 62
  • 3
    Nice ! but the file (and the so the folder) still appears as modified. – Loda Jun 29 '10 at 08:09
  • Yes, I am having the same issue. All this does is prevent against accidental update/commital. – Sled Feb 15 '12 at 18:24
  • 2
    As previously stated, this is perfect all except it shows that the file has been modified. It's better than having to uncheck all those files every time I commit, though. – Andrew Larsson May 07 '12 at 16:10
  • for the command line version of this feature see A.H. 's answer to http://stackoverflow.com/questions/8644379/svn-how-to-ignore-a-modified-file-on-commit – PMorganCA Jul 24 '15 at 14:19
  • That worked for me but only for files. Is there a solution for folders? – machinery Feb 03 '16 at 20:56
12

if you use Subversion 1.5.x or higher you can use changelists:

svn cl COMMIT /path/to/project/*

svn cl NOT_COMMIT /path/to/project/Makefile

Note: with second command Makefile will be removed from first changelist. You can ignore the warning.

Do not commit the second changelist.

do commits via:

svn ci --cl COMMIT -m"<LOG MESSAGE HERE>" 

Important: If you commit without --cl option, ALL your changes will be committed

Peter Parker
  • 29,093
  • 5
  • 52
  • 80
  • 1
    svn cl may not be a good option, because it doesn't support adding directories to changelists. This is a problem if there are directories that you svn add'ed that you want in your commit. – allyourcode Jul 02 '09 at 20:34
  • 2
    changelists seem useful, but I don't think they really apply here. It's a different use case. They might work if the commands by default ignored files that were in a changelist - that would be really useful. But unless I'm mistaken, that's not how it works. If you don't specify a changelist on a command, then it behaves as if changelists don't exist, correct? So even if changelists supported directories, it wouldn't be an ideal solution. You'd have to manually move the files you really want to checkin into a changelist. I'd rather only manually mark the files I DON'T want to checkin. – andersonbd1 Aug 14 '09 at 13:00
1

The closest safe solution I can think of is to use a personal branch.

Gleb
  • 2,404
  • 1
  • 13
  • 7
  • 1
    How does that help? When you want to merge back into trunk, you'll have another (worse?) problem: NOT merging the files you wanted to ignore. – allyourcode Jul 02 '09 at 20:31
  • 1
    You can commit your personal change into your personal branch with a message saying 'do not merge' and watch out for that message when merging, it will soon be buried under more recent changes anyway; you can even mark that revision as already merged which should prevent an accidental merge. BTW I didn't know about changelists and they are definitely better than a branch for that purpose. – Gleb Jul 09 '09 at 14:25
-3

Use svn export to export the file so it's not under version control.

http://svnbook.red-bean.com/en/1.0/re10.html

edit: However I believe this has to be done on a per-directory basis, so you'd have to reorganise your files somewhat.

I can't test this at the moment, but would a sparse checkout help you here?

http://svnbook.red-bean.com/nightly/en/svn.advanced.sparsedirs.html

John Carter
  • 53,924
  • 26
  • 111
  • 144
  • Doesn't work, still part of the repository and shows up as modified – fuad May 21 '09 at 22:30
  • 1
    I'm not sure it's possible to have exported files within a versioned directory. – John Carter May 21 '09 at 22:37
  • I'm not sure why this has been voted down so heavily. This works in a number of situations where other solutions don't. Most notably it works for me because I had two extra requirements. 1) No TortoiseSVN (I'm in OS X) 2) I don't want to adjust my habits to account for change lists. Edit: Tested and working inside of a versioned directory btw. You can remove the given directory (from inside the directory) with "svn update . --set-depth=empty" and then you need to check it out again with "svn export --force svnrepopath/directory ." – radicaledward101 Dec 03 '13 at 16:38