14

Per accident I committed twice because I forgot to add two files. Can I remove a specific commit from the log?

screenshot of log

I want to delete commit № 4.

  • 2
    You may want to read this question: http://stackoverflow.com/questions/5566327/delete-all-traces-of-a-svn-commit – Riccardo T. Sep 10 '11 at 12:16

4 Answers4

13

The simple answer is "no", because Subversion doesn't know how to resolve the case when you add a commit, someone else updates their checkout, and then you remove the commit from history. There might or might not be a complex answer involving surgery on the Subversion storage.

millimoose
  • 36,982
  • 8
  • 75
  • 128
5
  1. AFAICS, you have not delete r4, but merge with r5, yes?
  2. In general, SVN commit history is immutable, as Sii said - and if you haven't rights delete/create repo - you can't do anything.

If you can delete current repo and create new with new history, you can try:

  • svnadmin dump for getting human-readable (barely, I have to say) repository-dump, grok format and edit dump, delete repo, svnadmin load to recreate the repo
  • another idea is (instead of editing dump) another SCM, which has a bridge to SVN (hg+MQ (histedit)+hg-git, f.e, will allow you to get repo and fold/delete changesets). For replacing old repository - see p.2 above
Anonymous
  • 10,357
  • 3
  • 37
  • 49
Lazy Badger
  • 87,730
  • 7
  • 72
  • 97
2

In your case, it's just necessary to modify the commit comment associated with commit #4 to reflect the actual changes you made. You can do that with Subversion by modifying the SVN repository configuration. See the Subversion FAQ.

sakra
  • 53,539
  • 13
  • 152
  • 136
-1

Why? Let Subversion keep the history - that's what it's for. Check in early and often. There's no need to erase commit #4.

duffymo
  • 293,097
  • 41
  • 348
  • 541
  • 1
    Because I didn't add Site.cc and Site.hh (I forgot to do that), but the commit message says I did. –  Sep 10 '11 at 12:17
  • 5
    @WTP: The canonical solution is just committing a ninjafix and commenting it accordingly. If you want a "neat", one-commit-per-work-package history, Subversion (or Subversion alone) might not be the right tool for that. – millimoose Sep 10 '11 at 12:19
  • If you did a clean check out of the project, would those two files appear? If yes, then you did commit them. Believe Subversion. – duffymo Sep 10 '11 at 12:21
  • 1
    Well the proper solution in this particular case is to modify the commit message after it was committed. – Andrew Oct 05 '17 at 12:08