How to merge two Subversion commits into one

I use a GUI program to interact with our SVN repository. There's a lot of times when I go to commit ten different files, but accidentally only select one and commit it. I then have to make another commit with all my other changes.

Is there a way to merge those two "duplicate" commits together into a single commit with a single message in the tracking program?

It's pretty trivial, but I am curious whether it's possible.

Answers


It doesn't sound like they're "duplicate" commits.

It sounds like you have 10 files that you commit separately in two commits (if I understand correctly).

I don't know if you can "un-commit" the first file, but you could do another commit to "revert" the repo to where it was before you made the accidental commit. This would allow you to commit all ten files in the same revision.

I don't know how to do it with a GUI/IDE.

From the command line you could do it like this:

  • accidentally commit file A in revision 5000

  • create a patch to revert the commit:

    svn diff -r 5000:4999 > revert.patch

  • apply the patch:

    patch -p0 < revert.patch

  • now your repo is where it was before the accidental commit

  • now you can commit all ten files together

There are probably many ways (some easier) to do this. I'm sure this answer will be down-voted!


In general, the idea of a revision control system is that you can't go back and change previous commits - that would remove a lot of the value as you could no longer guarantee what's in the revision control system is what you actually had at the time.

In the case of subversion, you could use svnadmin to dump out the repository, edit the dump and then restore it back again... but that's a lot of work for something which is of marginal value. Sounds to me like a better idea is to get a front-end which fits your workflow better, or to add some commit hooks which stop you making the bad commit in the first place.


There is no direct suuport for that in Subversion as far as I know (as opposed to git for example). However, you can undo changes and than make a new commit. You can refer here: http://svnbook.red-bean.com/en/1.2/svn.branchmerge.commonuses.html#svn.branchmerge.commonuses.undo

or if you use some GUI like tortoise for example, you might find the following shortarticle interesting:

http://markphip.blogspot.com/2007/01/how-to-undo-commit-in-subversion.html


Need Your Help

setInterval then update page title depending on the outcome

javascript jquery

I am using this code to retrieve notifications automatically

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.