git 推送大型 github 存储库失败,“无法推送到不合格的目的地:master”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28417845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Pushing a large github repo fails with "unable to push to unqualified destination: master"
提问by Maurício Linhares
I have a large git repo (created from an SVN repo) and I want to push it to github. Given it's large, I can't just try and push it directly, as it fails with a "pack too large" error.
我有一个很大的 git 存储库(从 SVN 存储库创建),我想将它推送到 github。鉴于它很大,我不能只是尝试直接推送它,因为它因“打包太大”错误而失败。
All good so far, I can push the repo one commit at a time. But when I try to do this what happens is:
到目前为止一切都很好,我可以一次推送一个 repo。但是当我尝试这样做时会发生什么:
git push origin 86c310d8a680d6d0e052fa7db89adb25348f3e54:master
error: unable to push to unqualified destination: master
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
So, there is no master branch at the remote repo yet, but I'm trying to push to it and it fails.
所以,远程仓库中还没有 master 分支,但我试图推送到它,但它失败了。
How do I fix this? Or how do I create an empty master branch at the remote so I can push to it?
我该如何解决?或者如何在远程创建一个空的 master 分支,以便我可以推送到它?
回答by hobbs
Push to refs/heads/master
, just this one time.
推到refs/heads/master
,就这一次。
git push origin whatever:refs/heads/master
git push origin whatever:refs/heads/master
That will create it unambiguously as a branch, and you'll be able to push to it normally in the future.
这将明确地将它创建为一个分支,并且您将来可以正常推送到它。
This works because there's no remote ref named master (it hasn't been created yet), the target ref isn't fully-qualified with refs/ so git can't figure it out based on that, and the source ref is a hash rather than a name, so it can't figure it out based on that either. By pushing to refs/heads/master it works because the second condition is true, and then afterwards master exists on the remote so the first condition is true
这是有效的,因为没有名为 master 的远程引用(它还没有被创建),目标引用不是完全限定的 refs/ 所以 git 无法根据它找出它,源引用是一个散列而不是一个名字,所以它也无法根据它来弄清楚。通过推送到 refs/heads/master 它可以工作,因为第二个条件为真,然后 master 存在于遥控器上,因此第一个条件为真
回答by M.Ferru
You can also create a new branch with
您还可以创建一个新分支
git checkout -b branchName
and then push your git repository to that branch
然后将您的 git 存储库推送到该分支
git push origin whatever:branchName
回答by Nutan
This worked for me: I created the remote branch on github UI and then pushed my local branch which had the same name to it. Try it in case other ways dont work. Other way would be creating a new branch locally and pushing an empty branch and later cherry-pick your commit and push again to your remote.
这对我有用:我在 github UI 上创建了远程分支,然后将具有相同名称的本地分支推送到它。试试吧,以防其他方法不起作用。另一种方法是在本地创建一个新分支并推送一个空分支,然后挑选您的提交并再次推送到您的远程。
Check this as well similar issue: When deleting remote git branch "error: unable to push to unqualified destination"
检查这个以及类似的问题: 删除远程git分支时“错误:无法推送到不合格的目的地”
回答by TBone
I had this same error and found that I'd spelled the name of my branch wrong. So you could find that double checking the branch name to ensure any capital letters etc are in the right place.
我有同样的错误,发现我拼错了我的分支名称。所以你会发现仔细检查分支名称以确保任何大写字母等都在正确的位置。