Git: Perhaps you should specify a branch such as ‘master’.

I got this error on GitBash in Windows. This happens when you clone from a non bare repository and you are trying to push again to that.
More on that here: http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master-master-branch-is-currently-checked

So use this instead:

git push origin master:masterOrigin

This will push your clones’s master branch to a new branch in origin called masterOrigin.

Similar error on Cygwin:

MARS-ROVER@MARS-ROVER-ST ~/SGGitClone
$ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 512 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To /home/MARS-ROVER/SGGit/.git
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/home/MARS-ROVER/SGGit/.git'

MARS-ROVER@MARS-ROVER-ST ~/SGGitClone
$ git push origin master:masterOrig
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 512 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To /home/MARS-ROVER/SGGit/.git
 * [new branch]      master -> masterOrig
Advertisements

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

%d bloggers like this: