How do I avoid checking in local changes to the SVN repository?

后端 未结 8 986
有刺的猬
有刺的猬 2021-01-05 08:19

I have to make local changes to my project files in order to get it to run in a different environment. Twice now I accidentally checked those changes in (and messed up ever

相关标签:
8条回答
  • 2021-01-05 08:39

    I always review the diffs of all my files before a commit, that way I can make sure I'm not leaving some debug code in and it gives me a second chance to review my changes.

    If you're running on a Unix/Linux machine with tksvn w/ tkdiff installed, you can check out a nice graphical representation of each diff one by one this with this command:

    for FILE in `svn status | grep -v ? | sed -n "s/^[MA]//p"`; do tkdiff $FILE; done
    

    Another smart way to double-check yourself is to check out a fresh copy of the repository and try to build and run it--that way you can catch if you forgot to add a file or broke something obvious.

    0 讨论(0)
  • 2021-01-05 08:40

    When I have a situation like this, I add the files that I do not want to check in to a change set labelled "DO NOT CHECK IN". My SVN client (SmartSVN, although Tortoise does also suuprt this) can then be set to ignore that change set, meaning that I don't accidentally check in those changes.

    The only downside to this is when you have made changes to files in the change set that you do actually want to check in - you then have to manually remember to check them in.

    0 讨论(0)
  • 2021-01-05 08:42

    I've had good luck using svn switch to keep personalized files from stomping on others' configurations. Given a normal trunk/branches/tags layout, make yourself a folder in branches containing your personalized configuration file. Then

    svn switch URL-to-personalized-config URL-to-standard-config
    

    This will cause edits to the config file to be saved off in your branch and not to the trunk. You get versioned edits to your config file, and can't easily mess up the trunk file.

    0 讨论(0)
  • 2021-01-05 08:52

    What client do you use?

    TortoiseSVN has a nifty feature that takes advantage of the changelist feature built into SVN. If you right click on a modified folder and choose "Check for Modifications," you can right-click on any of the modified files in that dialog and choose "Add to Changelist -> ignore-on-commit." From then on, whenever you perform a commit Tortoise makes sure not to add those files to the commit. See "Excluding Items from the Commit List" on this page.

    If you're not using tortoise, you could set up a similar changelist manually.

    0 讨论(0)
  • 2021-01-05 08:54

    I generally try to arrange things so the standard files SVN checks out can be overridden by a separate file which is svn:ignore-ed

    For example, I have a bash script which starts a Jetty web server using a config file. Normally it is jetty.xml, but if jetty-local.xml is present on the filesystem, that's used instead.

    (Of course, the obvious problem there is that when jetty.xml gets some updates, they won't be merged into jetty-local.xml, but that may be less of a problem than what you're already facing.)

    In a PHP project I used to work on, this was taken even further with two separate code trees - /system where all the system classes were checked out, and /local which mirrored it, but was empty unless a local class were added, in which case it was loaded in preference. That may well be getting too fancy for its own good.

    If it's configuration files which you own that are the problem, another solution I've used is to arrange to read them hierarchically (i.e. read in global.cfg.default, then overwrite with any settings in global.cfg.local).

    0 讨论(0)
  • 2021-01-05 09:03

    Solution depends on how many changes you're talking about. I work with .net websites so for most sites I'd have a different config file for each environment. e.g:

    web.deploy.config
    web.dev.config
    

    These would all be under source control. Then copy the one of these files to web.config on the server it's running on (leaving this file out of source control). Works for me.

    0 讨论(0)
提交回复
热议问题