Reputation: 2939
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 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
Upvotes: 1
Views: 2607
Reputation: 1323773
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
Upvotes: 2