Pushing a large github repo fails with "unable to push to unqualified destination: master"

GitGithub

Git Problem Overview


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.

All good so far, I can push the repo one commit at a time. But when I try to do this what happens is:

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.

How do I fix this? Or how do I create an empty master branch at the remote so I can push to it?

Git Solutions


Solution 1 - Git

Push to refs/heads/master, just this one time.

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

Solution 2 - Git

You can also create a new branch with

git checkout -b branchName

and then push your git repository to that branch

git push origin whatever:branchName

Solution 3 - Git

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.

Check this as well similar issue: https://stackoverflow.com/questions/10292480/when-deleting-remote-git-branch-error-unable-to-push-to-unqualified-destinatio/50581666#50581666

Solution 4 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMaurício LinharesView Question on Stackoverflow
Solution 1 - GithobbsView Answer on Stackoverflow
Solution 2 - GitM.FerruView Answer on Stackoverflow
Solution 3 - GitNutanView Answer on Stackoverflow
Solution 4 - GitTBoneView Answer on Stackoverflow