Subversion: prevent local modifications to one file from being committed?

前端 未结 13 554
名媛妹妹
名媛妹妹 2020-12-01 04:17

I have a Subversion working copy where I made some local modifications to one file. The modifications are only relevant to me, I do not want to commit them. (The version in

相关标签:
13条回答
  • 2020-12-01 05:01

    If you're on Windows, use TortoiseSVN. You can add files to the special "ignore-on-commit" changelist that behaves exactly as you described.

    0 讨论(0)
  • 2020-12-01 05:02

    Create a changelist with that file in it, and then just pay no attention to the changelist. The file will sit there waiting to be committed, but your regular commits, which work on the default changelist, will never pick it up.

    svn changelist mylocal file1
    

    will create a changelist called mylocal and assign the file file1 to it.

    0 讨论(0)
  • 2020-12-01 05:03

    Speaking of Tortoisesvn and changelists, it already comes with a changelist called ignore-on-commit, which does what you are looking for.

    0 讨论(0)
  • 2020-12-01 05:04

    I understand the problem you're having; probably this "forbidden" file contains configuration settings and the like that are only relevant to your local build environment. I've not found any way directly to tell SVN just to ignore changes in a versioned file, but here's a workaround I've used in the past.

    Assuming your file is called, say, "build.conf". Name the SVN versioned file something like build.conf.example. Then, in your Makefile or build script or whatever, you can automatically copy the build.conf.example to the real build.conf, which remains unversioned. Then you svn ignore build.conf and each developer can then make any local changes they need to it.

    But "there must be a better way"...

    Edit: Almost identical question here: SVN: Is there a way to mark a file as "do not commit"?

    0 讨论(0)
  • 2020-12-01 05:05

    Actually, a pre-commit script would do the job.

    Write a pre-commit script that executes 'svnlook diff' and rejects the commit if there is a property named 'nocommit' being set in the changeset.

    Then, in your working copy, you can just set a 'nocommit' property on any file that shouldn't be committed. Any subsequent commit will fail if any file has the 'nocommit' property. If you later do need to check in changes on the file, all you have to do is remove the 'nocommit' property from your working copy.

    0 讨论(0)
  • 2020-12-01 05:05

    This question is in the Subversion FAQ. But the answer is not very helpful if you do not control the repository.

    Maybe try to manage your local copy with git on top of subversion. There is a simple course for git available. You can then use git-svn for tracking changes in svn repository and for commiting your changes. It will need some learning and training through.

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