While waiting for the sysadmin to set up the gerrit repo, I made my own branch. He just now sent me the address of the repo. I set it for origin and somehow pushed my last commit. Cloning the repo works fine, however git branch -r
returns nothing. What is going on here?
$ git init
# made some comits
git config remote.origin.url ssh://gerrit.mm-sol.com/branchname
$ git push origin SH1-of-my-last-commit: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.
error: failed to push some refs to 'ssh://gerrit.mm-sol.com/apps/phone-shaker'
$ git push origin master
Counting objects: 85, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (85/85), done.
Writing objects: 100% (85/85), 20.95 KiB, done.
Total 85 (delta 49), reused 0 (delta 0)
remote: Resolving deltas: 100% (49/49)
remote: Updating references: 100% (1/1)
To ssh://gerrit.mm-sol.com/branchname
* [new branch] master -> master
To see local branches, use the git branch command. The git branch command lets you see a list of all the branches stored in your local version of a repository. To see the remote branches associated with your repository, you need to append the -r flag to the end of the git branch command.
Hence, You need to make at least one commit before you can see the other branch listed by the git branch command. Save this answer.
This is a common issue and usually happens in VS Code IDE. Because Visual Studio Code sometimes doesn't update the branches automatically. In that case we have to manually fetch the branch for VS Code.
Try this:
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin
and then try git branch -r
again.
In the future when setting up remotes, it's preferable to use the following command instead of git config
:
git remote add <remotename> <remoteurl>
e.g.
git remote add origin ssh://gerrit.mm-sol.com/branchname
This will automatically set up both the url
and fetch
configuration.
Try to git push -u origin master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With