I want subversion to commit a file even if it's unchanged. Is there a way to do this?
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).
if you check out a project you can commit it. If nothing has changed it doesn't update the revision number or the files.
If it's a text file just add some whitespace, such as a line feed.
You can't, and you shouldn't. You should also thank Subversion that it refuses.
Now, what problem are you really trying to solve?
It does not really make much sense... :)
For at least two reasons:
- The file will still be a part of the new revision even if there were no changes to it.
- Subversion only stores the differences between the files in the two revisions. If the files are identical what would be stored?
Why would you want to do this? What are you trying to do?
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.
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.
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.
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.
Another reason to have forced commits (at least for conflicting or not up to date files).
I use one version control system (w/ repository in a remote server). This one is the main and used by the team. And I installed SVN to use locally for the same projects.
I want to use SVN to, in short, 1. force commit all the files to have save current state with my changes ready for the central repository; 2. experiment (for example by applying other algorithms in the code), commit my local changes to SVN, keep track of those changes; 3. then, be able to revert all or some of my saved state if necessary.
It doesn't make sense to create new SVN repository for every experiment.
After working a while on the code without sync-ing with SVN I can see many missing/conflicting or "not up to date" files. Those are the problem. It doesn't make sense to resolve conflicts one by one here. I just want force commit.
I want to mark code to belong to a particular Jira ticket, code is connected to a Jira ticket via a comment made on that piece of code. Can you comment on code that's not being checked in?
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.
Hey guys,
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? :>