如何检查存储库是否裸露? [英] How do I check if a repository is bare?

查看:81
本文介绍了如何检查存储库是否裸露?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到警告

 警告:您没有指定任何推送参数,而当前的远程
警告:尚未配置任何推送参数。此
warning:case中的默认操作是推送所有匹配的refspecs,即所有分支
warning:本地和远程存在的都将被更新。这可能是
警告:不一定是你想要发生的事情。
警告:
警告:您可以指定在这种情况下要执行的操作,以及
警告:通过将push.default配置为:$ b $,避免再次看到此消息b警告:'没有':不要推送任何东西
警告:'匹配':推送所有匹配的分支(默认)
警告:'跟踪':将当前分支推送到正在跟踪的任何
警告:'当前':推送当前分支

这是(我认为)不是光秃的。然而,我希望遥控器是裸露的,并且目录(形式为 foo.git )在其中没有.git目录。如何检查它是否是裸露的?



其他信息:远程存储库位于计算机上,其中包含git 1.5.4.3,本地仓库有git 1.6.3.3。这两台机器都是Ubuntu--本地的是Karmic Koala,远程的是旧版本。

它是裸露的?



正如下面的答案( upvoted)通过 jberryman ,如果您有权访问远程回购,您可以运行它:

  git rev-parse --is-bare-repository 

早在 commit 493c774,Git 1.5.3 (2007年9月)和 commit 7ae3df8 Matthias Lederhofer( matled


何时存储库是裸露的true,否则为false。






使用(从 git config ):

  git config --add push.default current 

指定默认推送的内容。



或:

  git config --global push.default matching 

如果你有许多存储库。


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


检查警告是否后面没有错误信息,如 SO question




因此,您的目的地回购可能是空的回购,但正如 Sensible Git Refspecs
$ b


当您执行 git pull fetch时, push 和其他一些你需要为当前仓库指定一个 refspec
A refspec 描述了本地引用和远程引用之间的映射,所以你可以推动(或拉等)主分支头并将其存储为起始分支头。基本上它是一种在回购之间映射分支的方法。


另请参阅在git中共享仓库的概念






注意:这是真的比来自 Git1.6.3 , :


git push 到当前签出的分支中默认情况下为拒绝。

您可以通过在接收存储库中设置配置变量 receive.denyCurrentBranch 来选择发生这种情况时应该发生的情况。


但是我不认为这是您现在看到的。




正如所有关于光秃秃的回购 - 什么,为什么,以及如何解决一个非光秃秃的推动(在底部)


为了使它成为真正的裸回购,只需删除除 .git 之外的所有文件,然后 mv .git / * 。 rmdir .git

最后,编辑名为 config 的文件并更改 bare = false 至 bare = true



$ b $因此,如果您的目标回购有 bare = true config 文件,它是一个裸回购。

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.

解决方案

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.

这篇关于如何检查存储库是否裸露?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆