“Impossible to push references” when pushing into an empty git repo

点点圈 提交于 2021-02-08 11:31:25

问题


I'm trying to get a branch from a git project and put it into another git repo however when I do this and trying to push I have this error

the source reference specifier refs/heads/master does not correspond to any reference error: impossible to push references to "origin"

Also I've noticed that the empty project has no branch even the master one.


回答1:


If you have cloned the first project, and want to push a branch to a second remote empty repository (no commits), you would do:

cd /path/to/cloned/first/project
git remote add second https://url/second/empty/repository
git switch <theCorrectBranch>
git push -u second <theCorrectBranch>:main

That would push <theCorrectBranch> to the branch main of the second remote empty repository.



来源:https://stackoverflow.com/questions/65510951/impossible-to-push-references-when-pushing-into-an-empty-git-repo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!