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 ?
Expanding on the.malkolm‘s answer:
If you look in
.git/config, you’ll find a line likefetch = 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!