1

I am trying to move one of my SVN repositories to a new repository in GitHub.

Since I don't have much experience yet with Git, I'm trying to follow instructions I found on Stack Overflow and GitHub.

  • I only need the trunk of the project, which is in a repository together with several other projects.
  • I want to keep my history
  • I am not planning to go back to SVN soon

I executed the following commands. What am I missing/doing wrong here?

git svn init https://svn.my-domain.org/svn/MyRepository/MyProject/trunk/
git svn fetch
git remote add origin [email protected]:MyUserName/myrepository.git
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git push

The last command gives me the following error:

To [email protected]:MyUserName/myrepository.git

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:MyUserName/myrepository.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I understand that I must merge my GitHub repository (witch has only the readme file) with the local Git repository with the files/history from SVN.

I tried in different ways the git push, but that didn't succeed. How should can I execute the push?

Thanks in advance

4
  • Your Git repo (on GitHub) currently has a README which doesn't yet exist in your local repo, so when you try to push your changes, the remote repo is rejecting them. As the hint suggests, try doing a git pull to integrate the remote files, followed by git push. Commented Oct 27, 2013 at 17:07
  • Bitbucket has a good step by step Migration Guide for Subversion to Git on Bitbucket You could just reuse for Github Commented Oct 27, 2013 at 17:35
  • @Graham, I tried the git push but that didn't work with the repository. However I just tried with another repository and it did work. No idea what was the difference! Thanks anyway Commented Oct 28, 2013 at 9:06
  • @MichaelVer, I'll use that if I need it again, thanks Commented Oct 28, 2013 at 9:06

1 Answer 1

2

If you don't care about GitHub initialization file (.gitignore or README.md), you can:

git push --force

If you do a git pull, that will add to your current commit one from GitHub with its content.
Then a git pull would work.

Don't forget that you can create on GitHub a completely empty repo, which means you can then push whatever history you want.
Simply unselect the "Initialize this repository with a README" option

https://github-images.s3.amazonaws.com/help/repo-create-name.png

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.