git rebase -i HEAD~8
I recently needed to create a new feature branch on the remote svn, work on it, and then merge it back into the trunk. It took a whole lot of digging to figure this out, so I thought I'd share what ended up working. I can't vouch for the optimality or safety of any of this. I just know that it worked for me.
First of all, I made sure to check out the repository using the --stdlayout option.
git svn clone svn+ssh://user@server/svn/repos/project --stdlayoutThen, to create a new remote svn branch called "new_feature",
git svn branch -m "Branch to add in new_feature." new_featureAnd check out the new branch locally
git checkout -b new_feature new_featureThen the usual. Hack, commit, etc. It's not a bad idea to first do "git svn dcommit -n" to make sure your dcommits will go to the branch directory in the remote repository.
When it's finally time to merge back into the trunk (this was the hardest part to find - this post at stackoverflow was really helpful), re-checkout the trunk to a new local branch, which I called "merge".
git checkout remotes/trunk -b mergeThis seems to be the key step. Merge the feature branch with the --squash option.
git merge --squash new_featureThen commit and dcommit. You may want to do a dcommit -n to reassure yourself that you're committing to the trunk.
git commit -m "Merge new_feature branch" git svn dcommit -n (make sure commit will go to trunk) git svn dcommitThat's it! You may want to clean up your branches. This is what I did.
git checkout remotes/trunk git checkout -b localtrunk git branch -D new_feature git branch -D merge