Here is a simple path of what I’m doing:
$ cd /newdir
$ git clone git@github.com:... .
$ git branch -m master github
$ git svn clone svn+ssh://... .
$ git branch -m master SVN
Then I have some scripts that do what is needed before pushing to Github.
I need the SVN and github branches because the files on both branches are the same but with different content. Before pushing files to Github I add some header. The two branches are also used to allow not all files on SVN go to Github.
All updates are from SVN branch to github branch. Occasionally I would add something on github branch that is not on SVN. I’ll never send files/updates from github branch to SVN branch.
My problem 1 is that every time I do git svn fetch, a new master branch is created. How can I tell git svn fetch to use SVN local branch instead of master local branch?
After every:
$ git svn fetch
I could:
$ git checkout SVN
$ git merge master
$ git branch -d master
But does not look as a smart way of doing it.
Then I have a problem telling my local git that the local github branch is the remote/master branch at Github. The command
$ git push git@github.com:...
That worked perfectly before renaming local branches, now is not doing what I want.
So my 2 questions:
1 - Telling git svn to always use local SVN branch when getting updates from SVN server
2 - Telling git that local github branch is remote master branch at github
You can not use merge with SVN based branches (read the
git svnmanual; it very carefully states this in multiple places). If you need to merge, do it the other way where the SVN tree is merged into other branches (but never never merge something else into the SVN tree).Let
git svnhave themasterbranch and if you need to do development in a separate branch, use another one for yourself (saymaster2). Then when you want the work in it commited to the master branch, do:And when you add the github master repo, do it in a separate branch:
And simply always do the above to pull into the github specific branch. But you’ll likely run into issues with the github server when you need to push back into the github stream after doing rebases and thus will need to be mean and use
push -fto force update the github tree after a diverge.And ok, technically, I lied about not being able to merge into the SVN tree. But really, you’ll save a lot of headaches if you don’t. The reality is that
git svnisn’t meant to be a fully integrated git system. It’s really just a “better SVN client” than SVN itself. You really can’t usegit svnand expect to get the full power of git itself. Sad, but unfortunately true. I know because I’ve been down your path already and am doing what you want to do. The upshot is that you really can’t do merging and have it all play nicely together. SVN just can’t handle it.