driis
driis

Reputation: 164341

git-svn - cloned a single branch, now dcommit to another branch?

I have been using git-svn to work remotely on a spike for a new feature. Now I want to commit my changes to SVN, but on a different SVN branch than the one I first cloned. How do I do that ?

The original branch has changed, and I am not ready to merge the two. I would like to create a new SVN branch from the original branch, and commit the changes I have in git.

I have a shallow clone of just the one SVN branch:

git svn clone -r:HEAD svn://***/branches/main
git branch MySpike
git checkout MySpike
// Did some work, a lot of commits.

How do I commit my changes back to another SVN branch ? Is it possible ?

Upvotes: 2

Views: 231

Answers (2)

me_and
me_and

Reputation: 15654

Expanding on the.malkolm's answer:

If you look in .git/config, you'll find a line like fetch = branches/main:refs/remotes/git-svn. Add another similar line, referring to the name of the remote branch you want to commit to, and a name to give it locally (or, for the Subversion trunk, fetch = trunk:refs/remotes/trunk).

Then run git svn fetch. That'll download the history of the branch you've just added; feel free to limit the revisions it fetches if that's what you need.

Then rebase onto the new branch, and commit from there!

git rebase $(git merge-base remotes/git-svn MySpike) MySpike --onto remotes/newbranch
git svn dcommit

Upvotes: 1

the.malkolm
the.malkolm

Reputation: 2421

After you managed to configure two svn branches (just modify .git/config file). Here is how to rebase all code you did on top of svn/original/branch in the branch named cool/feature to another svn branch svn/another/branch:

git rebase --onto svn/another/branch $(git merge-base svn/original/branch cool/feature) cool/feature

Upvotes: 1

Related Questions