Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge two Subversion commits into one

Tags:

svn

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.

like image 294
jdp Avatar asked Jan 01 '26 04:01

jdp


1 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!

like image 129
jahroy Avatar answered Jan 06 '26 11:01

jahroy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!