views:

422

answers:

5

I got very used to git's way of having to touch every file you want to commit, and, while at it, double-check the diff. Now at work i have to use svn and i keep commiting stuff accidentially. Is there a way to make subversion behave like git in that i have to tell every file explicitly that should be included in the next commit?

+4  A: 

You could create a changeset that lists only the files you want to commit and then commit the changeset. If you're diligent about deleting changesets when you're done with them and never commit without a changeset, I think that would work for you. The easier solution would be to use a graphical client (such as TortoiseSVN, but there are others for all platforms with similar functionality) which shows you a list of the files that are going to be committed at the time it prompts for your login message. Then if you click "Commit" without reviewing them, it's not because it didn't tell you what it's going to do :)

rmeador
+1, as I didn't know about this feature, but they are actually called "changelists" in subversion.
rq
ah, crap... I knew I should have consulted the docs instead of writing from memory, but I got lazy. Sorry.
rmeador
good suggestion, thanks :) i know that GUIs should be able to handle this, but in practice i haven't found one that doesn't mark all files to be committed by default (opt-out). I think i will go with git-svn though, because i'm most familar with git-gui.
A: 

I usually commit from some IDE, like Emacs, where I can manually choose set of files to commit.

Eugene Morozov
+5  A: 

An alternative method would be to use the git-svn bridge at work, unless there are reasons as to why you can't. No one but you will have to know that you're actually using Git. This way you get all the benefits of Git while actually using Subversion.

sebnow
+2  A: 

Specify the files on the command line

svn commit -m "My commit message" folder/file1.c

Rory
A: 

To follow on Rory's answer, if you want to enforce explicit file commit behavior, you could write a batch or shell script that checked to make sure you had at least one argument other than the commit message and returned an error if you didn't. That would at least give you a reminder to explicitly put the file names in.

I always do an svn stat and diff before committing anyway, so the stat usually reminds me that there may be things that I didn't want to check in just yet.

brokenbeatnik