24

I'm getting the warning

warning: You did not specify any refspecs to push, and the current remote
warning: has not configured any push refspecs. The default action in this
warning: case is to push all matching refspecs, that is, all branches
warning: that exist both locally and remotely will be updated.  This may
warning: not necessarily be what you want to happen.
warning:
warning: You can specify what action you want to take in this case, and
warning: avoid seeing this message again, by configuring 'push.default' to:
warning:   'nothing'  : Do not push anything
warning:   'matching' : Push all matching branches (default)
warning:   'tracking' : Push the current branch to whatever it is tracking
warning:   'current'  : Push the current branch

which is (I think) a warning that remote is not bare. Yet I intended remote to be bare, and the directory (which is in the form foo.git) doesn't have a .git directory in it. How do I check that it is bare?

Extra information: The remote repository is on a computer with git 1.5.4.3, and the local repository has git 1.6.3.3. Both machines are Ubuntu - the local one is Karmic Koala, the remote one is an older version.

Andrew Grimm
  • 70,470
  • 47
  • 186
  • 310
  • Just added the criteria which indicates a repository is a bare one – VonC Dec 02 '09 at 05:06
  • 3
    `$ git rev-parse --is-bare-repository` - credit **jberryman** [please upvote his answer](http://stackoverflow.com/a/14734826/495132) – Jake Berger Nov 03 '13 at 21:33

5 Answers5

41

How do I check that it is bare?

As mentioned in the answer below (upvoted) by jberryman, if you have access to the remote repo, you can run in it:

git rev-parse --is-bare-repository 

It was introduced as early as commit 493c774, Git 1.5.3 (Sept. 2007) and commit 7ae3df8 by Matthias Lederhofer (matled).

When the repository is bare print "true", otherwise "false".


You could use (from git config):

 git config --add push.default current

to specify what you want to push by default.

or:

 git config --global push.default matching

if you have many repositories.

current: push the current branch to a branch of the same name.

Check also if the warning was not followed by an error message like in this SO question.


So your destination repo may be a bare one, but, as said in Sensible Git Refspecs:

When you do a git pull, fetch, push and some others you need to specify a refspec for the current repository.
A refspec describes the mapping between the local reference and the remote one, so you can push (or pull etc) the master branch head and store it as your origin branch head. Basically it’s a way of mapping branches between repos.

See also "concept of bared shared repository in git".


Note: it is true than from Git1.6.3, :

"git push" into a branch that is currently checked out will be refused by default.
You can choose what should happen upon such a push by setting the configuration variable receive.denyCurrentBranch in the receiving repository.

But I do not think this is what you are seeing right now.


As mentioned in "all about "bare" repos -- what, why, and how to fix a non-bare push" (at the bottom)

To make it a "real" bare repo, just delete all the files except .git, then mv .git/* .; rmdir .git.
Finally, edit the file called config and change bare = false to bare = true.

So if your destination repo has a config file with bare = true, it is a bare repo.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
39

It doesn't sound like that was your problem, but to actually answer the question you asked in the title: you can run...

$ git rev-parse --is-bare-repository

...to query if a repo is bare or not. Returns 'true' or 'false'.

jberryman
  • 15,764
  • 4
  • 39
  • 77
3

The message you’re getting means that your remote repository is empty (which has nothing to do with being bare). When pushing into a remote repository for the first time you need to specify what to push:

git push origin master

This will push your current master branch to the remote repository. Subsequent invocations of git push will pushing “matching” branches, i.e. if there’s a “master” branch in the remote repository your local “master” branch will be pushed to it.

Bombe
  • 74,913
  • 20
  • 118
  • 125
  • You can also say "git push --all" to push everything in the local copy to the remote. (After converting from Subversion into 300+ git repositories, I'm painfully familiar with this command!) – ebneter Dec 02 '09 at 07:12
  • Are you referring to the remote repository being bare, or the remote branch of my local repository? – Andrew Grimm Dec 02 '09 at 22:32
  • Neither, that’s the point. The message you are getting has nothing to do with any of your repositories being *bare*. It’s about your remote repository being *empty*, i.e. there are no commits in it, no branches, no nothing. – Bombe Dec 03 '09 at 08:02
  • The remote repository has been previously used as a remote repository quite often (although under 1.5.x), but the local repository is new. Would that be consistent with your diagnosis? – Andrew Grimm Dec 03 '09 at 22:41
1

try

 $ git config --get core.bare
Newton fan 01
  • 421
  • 5
  • 14
0

Open the config file in the .get directory and look for bare = true.

Bill Heitstuman
  • 885
  • 1
  • 8
  • 21