2

I am trying to migrate my projects from svn to git, based on steps given in this url: https://learn.microsoft.com/en-us/vsts/articles/perform-migration-from-svn-to-git?view=vsts#push-repository-to-a-bare-git-repository

But while pushing repository to bare git repository, I am getting below error:

C:\Git_Workspace\git_Repo>git push bare
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '../new_bare_repo.git'

I found one similar question here svn to git conversion no refs in common solution there is not helping but one comment suggested to add master like:

git push bare master

But it is not pushing my projects in bare repo just creating master file.

Any help to guide me what's happening in here is really appreciated..

Manvi
  • 1,136
  • 2
  • 18
  • 41

2 Answers2

4

It’s usually unnecessary to push local git repo to a local bare repo unless you want to treat the local bare repo as your remote git server.

If you want to hosted the remote repo into 3rd-party (like github, bitbucket VSTS git repo etc), you can push to the remote repo directly:

# After migrate svn repo to local git repo by git svn clone command
cd reponame
git remote add origin <remote repo URL>
git push origin --all
Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • Thanks for reply. Can you please also guide on this: we have one old code (project) in svn branch rather than trunk. How to do git clone on that? – Manvi Apr 03 '18 at 15:31
  • You just need to specify the subdir where the code located, such as `git svn clone --trunk=/relative/path/to/the/subdir`. – Marina Liu Apr 03 '18 at 15:56
1

There are better ways of converting a svn repo to git. To name a few, Please refer to below documentation:

Official: https://git-scm.com/book/en/v2/Git-and-Other-Systems-Migrating-to-Git Bit bucket: https://www.atlassian.com/git/tutorials/migrating-overview

All of them refer to the same process but I found these documentations are pretty well written.

TonyBoy
  • 26
  • 3