How can I force subversion to commit an outdated file?

34,583

Solution 1

Instead of checking out 631, do a REVERT to 631. Then you can change and check in.

Solution 2

The question is a bit old, but the answer may be useful for future reference:

Well, actually, one is not supposed to commit outdated files to SVN. The server itself refuses those files for security reason. One thing to do is to make an update from the last version, but keeping your "outdated" files during the merge process automatically:

svn up --accept mine-full

In other words, this will perform the update, but ignore any incoming merge.

Solution 3

If you can't do a REVERT to version 631, do the following:

  • Save your changes someplace outside your work area.
  • Update your work area to version 632 (HEAD).
  • Reapply the changes to your work area.
  • Commit.

Solution 4

I also want to have this feature. Why isn't there a command similar to svn commit --force-overwrite-new-version?

Copy SVN revision 631 to SVN revision 633, and then you can commit your changes to SVN revision 634.

svn copy remote_url@631 remote_url
svn commit

P.S. Neither does git have this feature. There is no such command as git merge foo --force-overwrite.

Sometimes the requirement changes, so some code that is committed becomes useless. It happens really often, so overwriting code is vitally useful. I wonder why neither svn nor git has this feature. What a stupid design!!!

Share:
34,583
Bartlomiej Grzeskowiak
Author by

Bartlomiej Grzeskowiak

Updated on April 01, 2020

Comments

  • Bartlomiej Grzeskowiak
    Bartlomiej Grzeskowiak about 4 years

    I would like to "overwrite" my last commit with the previous version. I tried to checkout the version 631, do some changes, and commit it as version 633. But svn doesn't agree, because version 632 exists.

    What is the easiest way to do it? It is a multi-file commit. I don't want to make it manually.

  • Bartlomiej Grzeskowiak
    Bartlomiej Grzeskowiak almost 13 years
    This is one of the solution, but it requires manual merge. I work on kernel and "Save your changes someplace outside your work area" is really annoying.
  • Bartlomiej Grzeskowiak
    Bartlomiej Grzeskowiak almost 13 years
    Thank you. This one works. I made the checkout of Head revision (633). Update to old one (631), apply the changes and commit. This works.
  • GlenPeterson
    GlenPeterson over 11 years
    I just had subversion choke on several folders that I had moved all the files out of. I made a backup of my work, then reverted just the specific folders in question. I did not use -R to recurse the files in those folders, just reverted the folders themselves. Then it all checked in fine and I went back and did a svn rm to clean up the folders and checked them in fine. Little high-stress moment though... Thanks for the tip!
  • bkr
    bkr about 10 years
    Be aware that while it will ignore incoming merge it will still restore missing files that have not been flagged in SVN as deleted.
  • dan carter
    dan carter over 8 years
    how do i revert to 631? 'svn revert' does not accept a revision number and the help page indicates the command is only for discarding local changes.
  • Victor
    Victor over 6 years
    This is not a good idea. Because locally deleted files will be restored. and locally unchanged files will be updated.
  • Kevin Crum
    Kevin Crum about 2 years
    if i recall correctly in git you can do a force where you make the HEAD your commit