tags:

views:

98

answers:

4

Is it possible to commit a single change to SVN without committing any of the other changes in the file?

For example, I have a file, config.properties, source controlled under SVN, and my local copy of this file contains numerous changes that are only relevant to my local environment. However, I want to commit a new config entry to this file so that my team mates can pick this up, but I don't want to lose my local changes.

Is there any way to do this?

+3  A: 

No, this isn't possible. Just svn checkout that file in a separate location and make the change their and merge it back into your other changes.

jeffamaphone
rmcc
For every project "prj" I work one, I very quickly find myself having a checkout "prj_clean" which is always up to date and is there just to do these little changes that need to be done immediately while I'm working on some feature that takes a day or two until I can commit it. Doing this, you can even use your favorite diff/merge utility to merge changes from "prj" to prj_clean" and check them in without checking in your half-baked feature.
sbi
+4  A: 

I'd suggest having a template config under the svn and having a local config ignored. This way you'd be able to do what you want: update template, merge with with local config and you're good to go.

SilentGhost
+2  A: 

It's not possible easily. But, the workaround is:

  • copy your modified config.properties somewhere safe outside of your working folder
  • revert config.properties
  • apply only the change you want to commit to config.properties
  • commit config.properties
  • copy your backup (safe copy) over config.properties in your working folder to get your changes back that you did not want to commit
RedFilter
A: 

In your specific case, I second silentghost's suggestion. I never keep live copies of my config files in the repo, only template files. This has other benefits: You will never accidentally overwrite your production config files on update, you can keep sensitive info like database passwords out of the repository, and everyone can have their own development setup that suits their needs/preferences. When a new config line is required, just check it into the template and notify the other developers they need to merge it with their local copies. (Or, maybe look at abstracting the config file into one that changes with each environment (db connection, etc.) and one that doesn't change (constants, language vars, etc.) and that can be part of the repo.

That said, for the general need to merge a single line change into the repo, Orbman and jeffamaphone are correct. (Orbman would get my vote for most comprehensive answer, but I had already voted for SilentGhost.)

Chrisbloom7