Search code examples
gitsvn

How to push certain branches into git repository?


I'm trying to convert svn repository into git. I've already cloned svn repository on local computer. And now trying to push it into git. Here are my steps:

git remote add origin https://my-gitlab/myproject.git
git branch -a
git tag

git push origin master feature_1 feature_2 feature_n tag_1 tag_2 tag_n

And i got error on push

error: src refspec feature_1  does not match any
error: src refspec feature_2  does not match any
error: src refspec feature_n  does not match any
error: src refspec tag_1  does not match any
error: src refspec tag_2 does not match any
error: src refspec tag_n does not match any

So i can't push it into git.

I've run git show-ref and found all my branches in the output list.
Also when i ran git branch -a i noticed that all my braches are red but can't find any information if it ok or not.

Previously i've already convert smaller svn repository into git with the same commands. But now i can't find what i'm doing wrong?

UPDATE git branch -a output

git branch -a
* master
  remotes/svn/feature_1
  remotes/svn/feature_2
  ....
:...skipping...
* master
  remotes/svn/feature_1
  remotes/svn/feature_2
  ....
:

* master
  remotes/svn/feature_1
  remotes/svn/feature_2
  ....
(END)

Solution

  • Locally, the svn branches, from the output you provided there, they are setup as being on the remote svn. Now, in order to push a branch svn/some-branch into origin and assuming that the branch does not exist in the origin remote yet, you have to do it like this:

    git push origin svn/some-branch:refs/heads/some-branch
    

    That should work to push the branches (just provide multiple branches in a single push... or separate push commands).