I was puzzled by a Git error I saw today.
I simple create a git repo on the “server”:
mkdir /git/newRepo
git init /git/newRepo
Then on my workstation I cloned it and added a file:
git clone ssh://server/git/newRepo
cd newRepo
vi test
git add test
git commit -m “testing”
git push
and I get this error:
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as ‘master’.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to ‘ssh://server/git/newRepo’
From reading a StackOverFlow answer I understood that the issue on the server side is that the new Git repository is open on the master branch by the user that created it and so it prevents a push to it because it could corrupt it. One way was to make the repo a bare one but another it to get the remote use into another branch than master.
On the server:
vi README
git add README
git commit -m “README”
git checkout -b test
and after that command I can pull and push normally.
git pull
git push
Reference: