May 7, 2010

Git svn dcommit, interruption recovery

As usual, I was doing all my work in my local copy(Git) of a SVN repository, when everything was stable and pretty, I started pushing everything to the central server. But in the middle of the operation the network was shutdown, some of my commits couldn't be pushed and my working tree was a mess!!.

"Ok" - I said - "I just have to point to HEAD again... which was the commit number?". I couldn't remember the commit number(is not so easy to do, admit it) but that's not necessary, right?, just do a 'git log --all' and you will see your commits. But NOOOOOOOOO, all commits were up to the last SVN dcommit entry!!!.
                                                       * -> 'super commit'
                                                       * -> 'some other commit'
                                                      [*]-> 'where SVN commit crashed'

"Oh shit, oh dear Lord!!, don't worry, Git tracks content, can't lose my commits" - I said. But nevertheless all options I've tried, my commits seem to be lost.

After a few minutes reading Git's manual, I found this:
$> git rev-list --all --pretty=oneline
And.. YES!! all my commits are there, so, to make the long story short:
$> git checkout awfulCommitNumber
$> git svn rebase
$> git svn dcommit