如何检查存储库是否裸露?

And*_*imm 22 git

我收到了警告

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
Run Code Online (Sandbox Code Playgroud)

这是(我认为)远程不是裸露的警告.但是我打算将remote设置为裸,而目录(在表单中foo.git)中没有.git目录.我如何检查它是裸露的?

额外信息:远程存储库位于具有git 1.5.4.3的计算机上,本地存储库具有git 1.6.3.3.两台机器都是Ubuntu - 本地机器是Karmic Koala,远程机器是旧版本.

jbe*_*man 37

这听起来不像是你的问题,但要真正回答你在标题中提到的问题:你可以运行......

$ git rev-parse --is-bare-repository
Run Code Online (Sandbox Code Playgroud)

...查询回购是否裸露.返回'true'或'false'.


Von*_*onC 34

我如何检查它是裸露的?

正如jberryman 在下面答案(upvoted)中所提到的,如果你有权访问远程仓库,你可以在其中运行:

git rev-parse --is-bare-repository 
Run Code Online (Sandbox Code Playgroud)

早在提交493c774,Git 1.5.3(2007年9月)和提交7ae3df8Matthias Lederhofer(matled)引入.

当存储库裸露时为"true",否则为"false".


你可以使用(来自git config):

 git config --add push.default current
Run Code Online (Sandbox Code Playgroud)

指定默认情况下要推送的内容.

要么:

 git config --global push.default matching
Run Code Online (Sandbox Code Playgroud)

如果你有很多的存储库.

current:将当前分支推送到同名分支.

还要检查警告是否没有出现此SO问题中的错误消息.


所以你的目的地回购可能只是一个,但正如Sensible Git Refspecs所述:

执行某个操作时git pull,fetch, push您需要refspec为当前存储库指定一个.
A refspec描述了本地引用和远程引用之间的映射,因此您可以推送(或拉取等)主分支头并将其存储为原始分支头.基本上它是一种在回购之间映射分支的方法.

另请参阅" git中裸露共享存储库的概念 ".


注意:它比Git1.6.3更真实,:

" git push"进入当前签出的分支将默认被拒绝.
您可以通过receive.denyCurrentBranch在接收存储库中设置配置变量来选择在此类推送时应该发生的事情.

但我不认为这就是你现在所看到的.


如" 所有关于"裸露的"回购 - 什么,为什么,以及如何修复非裸推 "(在底部)

要使它成为一个"真正的"裸回购,只是删除所有文件除.git,然后mv .git/* .; rmdir .git.
最后,编辑调用的文件config并更改bare = falsebare = true.

因此,如果您的目标仓库有一个config文件bare = true,那么它就是一个简单的仓库.