You're using subversion and you accidentally checkin some code before it's ready. For example, I often: a) checkin some code, then b) edit a little, then c) hit up, enter to repeat the previous command which unfortunately was a checkin.
Is it possible to retract such an accidental checkin from the server with subversion?
See the SVNBook, specifically the 'Undoing Changes' section, and reverse merging.
To clarify, your initial change will still be in the repository. But you've now retracted it in a later revision. i.e. the repository has captured all your changes (which is really what you want! Unless you've checked in a plaintext password or similar!)
It is sometimes necessary to edit the repo on the server, for example when you've accidentally committed a password that's hard to change. Here's a method I believe to be completely safe (the answer from @David Fraser caused repo corruption for me). NB this method will only remove revisions from the end of the repo so is most useful if you notice your mistake immediately.
svnadmin dump -r 0:N > reponame.dump
svnadmin dump -r 0:6610 > reponame.dump
will remove revs 6611 onwardssvnadmin create reponame
svnadmin load reponame < reponame.dump
svn checkout
from the repo server.I would doubt it. One of the main ideas of a source control is that a repository does not loose any history. You can't delete history. The best you can do is get an older version and overwrite the current one with that. But the history logs will still show your mistake.
(Offtopic: What kind of IDE are you using that does something like that?)
Yes, this is really what Subversion is for.
What you need to do is just replace your copy with previous revision in SVN repository.
There are several options:
But I strongly recommend you to do the following prior to replace your local copy:
WARNING: The accepted answer (by David Fraser) should work with an SVN 1.5 repository, but with SVN 1.6 you must also delete
db/rep-cache.db
before the next commit or you'll corrupt your repository and may not realize it until the next time you try a complete checkout. I've seen subsequent complete checkouts fail with a "Malformed representation header" error.What is rep-cache.db, you may ask? The documentation on the FSFS layout says that you will lose "rep-sharing capabilities" if you delete this file; however, it will be recreated on your next commit. Representation sharing was added in 1.6.
NB: THIS PROBABLY WON'T WORK ON CURRENT VERSIONS OF SUBVERSION AND IS A BAD IDEA - but I've left it here for information
NB: Normally when you have checked in by mistake, you should just revert the commit - see the other answers to this question. However, if you want to know how to actually undo the effects of the commit and change the repository to be how it was before, there's some explanation below:
This isn't what you normally want, but if you really want to remove the actual committed version from the repository, then you can do a nasty rollback on the repository as follows (this assumes that
$REV
is set to the latest revision, which you are removing):svn revert -r $((REV-1))
)db/revs/$REV
anddb/revprops/$REV
db/current
and (for subversion 1.6 or greater)db/rep-cache.db
, and runsvnadmin recover .
db/rep-cache.db
to prevent attempt to write a readonly database errorsThis all assumes:
fsfs
-based repository1.5.0
(otherwise you have to manually editdb/current
and change the revision number rather than runningsvnadmin recover .
)I've done it when a huge file was committed to a repository that I didn't want to stay in the history (and mirrors etc) forever; it's not in any way ideal or normal practice...