How can I force subversion to commit an unchanged file?

SvnVersion ControlCommit

Svn Problem Overview


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

Svn Solutions


Solution 1 - Svn

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.

Solution 2 - Svn

As to answer why one would like to do forced commits. I've seen cases where someone used a commit message that was wrong or unclear. It's nice if you can perform a forced commit, where you can correct this mistake. That way the updated commit message goes into the repository, so it won't get lost.

Solution 3 - Svn

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.

Solution 4 - Svn

If it's a text file just add some whitespace, such as a line feed.

Solution 5 - Svn

Answering some people questioning this should be possible: for some reason svn doesn't recognizes differences between doc files, so I would like to force commit as well!

I am now moving documentation from static dirs, to svn. files are like UG_v1.2, UG_v1.3 etc. So just to keep history, I take 1.2, remove version from the filename and add and commit it to svn. Then I take the ver from the second one, copy it over the first one and want to commit it and newer version. File size and creation date changes (not mentioning what's inside the doc), but svn claims it's perfectly the same file and disallows me to commit. When I manually change the doc, svn sees the different. The heck? :>

Solution 6 - Svn

I don't think that's possible, but first of all why do you need to do that? If a file is unchanged it shouldn't be commited.

If you really want that file grouped with other files in a commit you could change something minor inside (add a space for example).

Solution 7 - Svn

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

Solution 8 - Svn

Ancient question, but here's one reason why someone would want to do this:

We use an svn "commit" to document the successful outcome of a code review. During the code review, a certain subset of files is examined (and potentially modified). But files that are found to pass the review as-is will remain unmodified.

The idea is to use the commit to document which files were reviewed. That should include the ones that were found to pass the review without any modifications. Hence the need to "re-commit" ("force-commit") them unmodified.

Solution 9 - Svn

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.

Solution 10 - Svn

Changing the property will NOT force the commit.

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

Solution 11 - Svn

I have the same problem with a trueCrypt volume.

I added a new property (as suggested above) "forceCommit1" and them I was able to commit the volume file. but only the property was commited not the contents of the file.

I removed the file and added it again to the svn

Solution 12 - Svn

I thought you could do it from the command line?

svn ci -force <filename>

I don't have a repository here to check that on, so I might be wrong.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpcorcoranView Question on Stackoverflow
Solution 1 - SvnAndrew EdgecombeView Answer on Stackoverflow
Solution 2 - Svnuser253217View Answer on Stackoverflow
Solution 3 - SvnMatView Answer on Stackoverflow
Solution 4 - SvnjohnstokView Answer on Stackoverflow
Solution 5 - SvnagataView Answer on Stackoverflow
Solution 6 - SvnrsliteView Answer on Stackoverflow
Solution 7 - SvnSergiy SokolenkoView Answer on Stackoverflow
Solution 8 - SvnendangeredView Answer on Stackoverflow
Solution 9 - SvnFojView Answer on Stackoverflow
Solution 10 - SvnFojView Answer on Stackoverflow
Solution 11 - Svnuser41806View Answer on Stackoverflow
Solution 12 - SvnendianView Answer on Stackoverflow