我正在尝试将我的一个SVN存储库移动到GitHub中的新存储库。
由于我对Git没有太多经验,我正在尝试按照Stack Overflow和GitHub上的说明进行操作。
我执行了以下命令。我在这里错过了什么/做错了什么?
git svn init https://svn.my-domain.org/svn/MyRepository/MyProject/trunk/
git svn fetch
git remote add origin git@github.com:MyUserName/myrepository.git
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git push
最后一个命令给出了以下错误:
To git@github.com:MyUserName/myrepository.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com: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.
据我所知,我必须将我的GitHub存储库(只有自述文件)和本地Git存储库与来自SVN的文件/历史记录合并。
我尝试了git push的不同方式,但是没有成功。我该如何执行推送?
提前致谢
答案 0 :(得分:2)
如果您不关心GitHub初始化文件(.gitignore或README.md),您可以:
git push --force
如果您执行git pull
,那么将从GitHub中添加其当前提交内容。
然后git pull
就可以了。
不要忘记你可以create on GitHub a completely empty repo,这意味着你可以推送你想要的任何历史记录 只需取消选择“使用自述文件初始化此存储库”选项