Git error on a new repository

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:

http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked

Advertisements

Published by

m5c

Java developper that loves photography and good coffee

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s