How can I force subversion to commit an unchanged file?

后端 未结 11 1092
孤街浪徒
孤街浪徒 2020-12-02 16:32

I want subversion to commit a file even if it\'s unchanged. Is there a way to do this?

相关标签:
11条回答
  • 2020-12-02 17:21

    I frigged this by deleting then re-adding the offending file. Not the nicest way to do it, and it probably broke the revision history, but it suited my purposes.

    Reason for wanting to do it: File was one of two executables built from the same source (with different #defines set). Minor change to source meant one had changed, one didn't. I wanted to record in the revision history that I had actually updated it to the latest version (even though there was no change).

    Maybe Morten Holdflod Møller's point that "the file will still be a part of the new revision" would cover this indication, but I think a log of the unchanged file did not show comments for that revision.

    0 讨论(0)
  • 2020-12-02 17:22

    If you want the file contents to remain unchanged (meaning that you can't merely change whitespace as johnstok suggested) you can always change one of the properties on the file.

    eg.

    svn propset dummyproperty 1 yourfile
    svn commit yourfile
    

    That will perform a commit without having to change the file.

    Just make sure that you don't use one of the special svn: properties. Anything else should be ok.


    Edit: A number of other posters have asked why someone would want to do this - presumably the people who have marked this answer down have also had the same concerns.

    I can't speak for the original poster, but one scenario where I have seen this used is when attempting to automatically synchronise activities on a Visual Sourcesafe repository with a subversion repository.

    0 讨论(0)
  • 2020-12-02 17:22

    The reason why someone wants to commit unchanged file is misunderstanding of how to revert to a previous version of a file.

    For example, one may revert the file index.html in the revision 680 by just updating it to a revision in the past, e.g. 650:

    svn update index.html -r 650

    but it does not solve the problem, because:

    svn status -u index.html
            *      650   index.html
    Status against revision:    680
    

    svn clearly says that index.html is modified remotely and you can't commit it, i.e. it "thinks" that index.html is old and should be updated to a newer revision. So the next svn update will bring index.html back to the revision 680.

    To really revert a file you should merge it in reverse order:

    svn merge -r 680:650 index.html

    and then commit it svn ci -m "Reverted to r650" index.html

    0 讨论(0)
  • 2020-12-02 17:23

    Actually, I have come across a reason to do a force commit. This probably isn't best practice but we put Truecrypt (http://www.truecrypt.org/) volumes in SVN because we need to keep a tight security on some shell script as it contains sensitive information. When a Truecrypt volume is created, it's binary data stays the same no matter what you do with it. So in effect, I can change the contents of the volume but the volume never appears changed.

    0 讨论(0)
  • 2020-12-02 17:23

    Changing the property will NOT force the commit.

    TortoiseSVN 1.4.5, Build 10425 - 32 Bit , 2007/08/26 11:14:13

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