Given multiple unpushed git
commits, is it possible to git-svn dcommit
only one of those commits?
e.g. I have commit foo, bar, and baz, but rig
(The following assumes your work is on master
.)
First, reorder your last three commits so that bar
is first.
git rebase -i HEAD~3
An editor will pop up with something like this:
pick 498e4f4 foo
pick 71547ae bar
pick abf09c6 baz
# Rebase 4d3fe72..abf09c6 onto 4d3fe72
#
# ...
Reorder them in the editor that pops up so that bar
comes first.
pick 71547ae bar
pick 498e4f4 foo
pick abf09c6 baz
# Rebase 4d3fe72..abf09c6 onto 4d3fe72
#
# ...
Git will spin for a few seconds and burp up a confirmation:
Successfully rebased and updated refs/heads/master.
Now you can temporarily roll back to the bar
commit (HEAD~2
means two commits back from HEAD
) and dcommit it:
git checkout HEAD~2
git svn dcommit
If you're paranoid like me, you can do git svn dcommit -n
first to be sure you're only committing what you want.
Now jump back to master
:
git checkout master
The last bit is to rebase so that master
syncs up with svn:
git svn rebase
It's a little fuzzy to me why this is required, but I'm guessing that dcommitting in a detached HEAD state has something to do with it.