Friday, October 17, 2008

How to "git svn dcommit" with uncommitted changes

If you committing directly off the master, and have some files modified locally that you do not want to push up to the SVN server, and you have not added them to the ignore list, then you will get a " needs update" error message when you try to do your "git svn rebase". The way to get around this is to stash the local updates, rebase and dcommit, and then unstash them:

git svn rebase --> "file.abs: needs update"
git stash (save local changes away)
git stash list (have a look at what is stashed)
git svn rebase
git svn dcommit
git stash apply (back to where we were before)

Alternatively, use a branch for local changes and merge them into the master. This way the master only contains files that are going back to the SVN trunk.


Nikos Dimitrakopoulos said...

Thanks a lot - I was confused for a moment with this error message from git svn!

Chris Cobb said...

awesome thanks!

Alexander Beletsky said...

Thanks, it helped me

Spiros said...

Instead of `git stash apply` one might want to do `git stash pop`, which applies the patch and removes it from the stash list, which is what you probably want to do with a temporary patch like this. Thanks!