views:

48

answers:

2

Let's say I have multiple commits in my local git repository that have not been pushed to svn. For example, these four commits on master.

A <-- B <-- C <-- D

A is the oldest commit not in svn and D is the newest commit.

How do I use git svn dcommit to only push A and B to svn, but keep C and D only in my local git repository?

Alternate workflows welcome.

+3  A: 

dcommit takes an optional argument specifying what to treat as HEAD during commits, so either of these work (where B is a reference to that particular commit, either by name if it has one or by hash):

git svn dcommit B
git svn dcommit HEAD~2
Michael Mrozek
I've tried this, and it causes problems for me. Sometimes it only commits A, then craps out. If A and B get committed, it doesn't rebase correctly, and commits C and D are left as changes in my working copy.I have git version 1.5.5.6.
haydenmuhl
+1  A: 

I've been thinking about this, and have a potential solution to my own problem.

I can create a local branch for each discrete task I'm working on. If I finish one piece of work and am waiting for a code review, I can create a new branch and start working on an independent task.

When a given task is complete, I run git svn rebase. I then rebase my local branch on top of master, fast forward master to the head of that branch, then dcommit.

My problem was that commits A and B were part of one task, and C and D were another independent task. C and D belong in a different branch, and never should have been committed on top of A and B.

The answers to this question...

http://stackoverflow.com/questions/1256189/git-svn-dcommiting-a-single-git-commit

Seem to indicate that only committing A and B isn't really possible.

haydenmuhl
This is exactly the workflow I use; all my commits are in separate branches, and I only merge a branch with master if I'm about to push it to svn
Michael Mrozek
Oh, and I think 1256189 is talking about it not being possible to commit *just* B; you can't cherry-pick a commit to dcommit
Michael Mrozek
Ah, thank you. Good info.
haydenmuhl