2009-12-02 55 views
18

我得到警告如何檢查存儲庫是否裸露?

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 

這是(我認爲)警告,遙控器是不是裸露。然而,我希望遠程是裸露的,並且目錄(格式爲foo.git)沒有.git目錄。我如何檢查它是裸露的?

其他信息:遠程存儲庫在計算機上使用git 1.5.4.3,本地存儲庫具有git 1.6.3.3。這兩款機器都是Ubuntu--本地機器是Karmic Koala,遠程機器是舊版本。

+0

只是添加了指示存儲庫是一個裸露的一個 – VonC 2009-12-02 05:06:39

+3

'$ git的REV-解析--is-裸repository'的標準 - 信用** ** jberryman [請給予好評他的回答](http://stackoverflow.com/a/14734826/495132) – 2013-11-03 21:33:45

回答

23

如何檢查它是裸露的?

正如提到的answer below(upvoted)由jberryman,如果你有機會到遠程回購,你可以在它運行:

git rev-parse --is-bare-repository 

它早在commit 493c774, Git 1.5.3推出(2007年九月)和commit 7ae3df8 by 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說:

當你做一個git pullfetch,push和其他一些人則需要爲當前指定refspec庫。
A refspec描述了本地引用和遠程引用之間的映射關係,因此您可以將主分支頭推入(或拉出等)並將其存儲爲起始分支頭。基本上它是在回購之間映射分支的一種方式。

另請參見「concept of bared shared repository in git」。


注:這是不是從Git1.6.3真實,:

git push」到當前已簽出將被默認拒絕的一個分支。
您可以通過在接收存儲庫中設置配置變量receive.denyCurrentBranch來選擇發生這種情況時應該發生的情況。

但我不認爲這是你現在看到的。


正如在 「all about "bare" repos -- what, why, and how to fix a non-bare push」(底部)提到

要使它成爲一個 「真正的」 裸回購,只是刪除除.git,則mv .git/* .; rmdir .git所有文件。
最後,編輯名爲config的文件並將bare = false更改爲bare = true

所以,如果你的目的地回購有config文件,bare = true,它是一個裸露的回購協議。

+0

+1。神奇的詞語是'git config core.bare' – 2014-09-29 19:17:38

3

您收到的消息意味着您的遠程存儲庫爲空(與裸露無關)。當推到遠程存儲庫中的第一次,你需要指定推什麼:

git push origin master 

這將推動你的當前主分支到遠程倉庫。後續調用git push將推送「匹配」分支,即如果遠程存儲庫中存在「主」分支,則將本地「主分支」分支推送給它。

+0

你也可以說「git push --all」將本地副本中的所有內容都推送到遠程。 (從Subversion轉換成300+ git倉庫後,我非常熟悉這個命令!) – ebneter 2009-12-02 07:12:53

+0

你是指遠程倉庫是裸露的還是我本地倉庫的遠程分支? – 2009-12-02 22:32:50

+0

這兩點都沒有關係。您收到的消息與您的任何存儲庫無關*無關。這是關於你的遠程倉庫是空的,即沒有提交,沒有分支,沒有任何東西。 – Bombe 2009-12-03 08:02:33

34

這聽起來不像那是你的問題,但實際上回答您的標題提出這樣的問題:你可以運行...

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

...查詢如果回購是裸或不。返回「true」或「false」。

+0

謝謝。這是我需要的。 – 2013-06-10 18:37:50

0

打開.get目錄中的config文件,並查找bare = true

0

嘗試

$ git config --get core.bare 
相關問題