When you work on a Git repository and an SVN remote, you will do a git svn dcommitto commit each Git commit from your Git repository directly to your SVN remote repository as a revision for each.

Easily fix git svn dcommit which fails.

I have had some hurdles and issues with git svnin general and since they are different source control systems, it may be hard to understand what to do when something goes wrong. If you do a git svn dcommitand it hangs or fails for any reason, you can resolve the problem easily.

Here are a few steps to follow to fix the issue:

1. Try Rebase First

First try and rebase the SVN repository onto the Git repository after committing in Git. Use this command:

Then try your git svn dcommitagain and if it still fails, continue with the following steps.

2. Do a Hard Reset

Do a reset on the Git repository to the last commit and this will update the index as well.

Go to the Git repository locally and then navigate to .git/logs/HEADand open that file in a text editor. The .gitfolder may be hidden on your computer and you can display it by showing hidden files and folders.

In the HEAD file, scroll down to the very bottom – to the very last commit – and copy the commit hash. Eg:

Then use this command below and replace *commit hash*with the copied hash:

3. Rebase Again

After resetting the Git repository, do a git svn rebase again:

The rebase could take some time but when it’s done, do your git svn dcommitagain, it should work fine.