1

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.

2 Answers 2

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

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.
1

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...

git-svn dcommiting a single git commit

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

3 Comments

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
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
What you can do is always work on a local-only branch in git, then you can cherry-pick commits from that branch onto the git branch that tracks your svn branch. I've used this exact workflow in the past.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.