I usually using git for versioning, but right now I am stuck with sources in a svn repository, so I am using git-svn to access that repository. However this seems to lead to some trouble, when I try to use local branches.
I usually only commit my local repositories about once a day, so I might have commits in my local master, that I have not yet send upstream. When I create a branch at this point, and then someone else commits to the upstream repository, all commits between the current one and the last one that was synced upstream get duplicated.
To make this clearer here a short picture:
A-B-C-D-E
\
\-F
The upstream repository is at A and the two branches are at E and F respectively. Doing a git svn rebase leads to:
A-G-H-B-C-D-E
\
\-B-C-F
Where G and H are the commits that were taken from the upstream repo. I already tried to get the two commits to the other branch as well by switching there and doing another git svn rebase. But this leaves me there:
A-G-H-B-C-D-E
\
\-G-H-B-C-F
So this leads to even more duplication of commits. Is there a clean way to handle this situation?
You can use
git rebaseto reapply any range of commits onto any particular commit, which sounds like what you want here. This technique works for moving any range of commits, but as I mention at the bottom, if you really only have a single commitFon your branch, then it’s easier to just cherry-pick. However, first I’ll describe how you would do it withgit rebase, since that’s more generally useful.(n.b. I’m going to rename your commits slightly since the two
Bs,Cs, etc. will have different commit IDs after rebasing.)After the first
git svn rebaseSo, if you were wanting to do this rebasing after the first
git svn rebaseyou would be in the situation:At this point, you could have done:
… which would have created:
After the second
git svn rebaseIf the situation is as you describe after the second
git svn rebase, that would look like this:In that case you could similarly do:
To create the graph:
… and you can just forget about
G'through toF''.However, in both of these cases, you’re only moving a single commit, so it’s probably easier to cherry-pick the commit. In other words, you could do:
I hope that’s of some use.