2017-07-25 32 views
3

git help clone--local選項的輸出執行以下操作:當使用git clone [path]時,--local實際上是否做了任何事情?

--local, -l 
     When the repository to clone from is on a local machine, this flag bypasses the normal "Git 
     aware" transport mechanism and clones the repository by making a copy of HEAD and everything 
     under objects and refs directories. The files under .git/objects/ directory are hardlinked to 
     save space when possible. 

     If the repository is specified as a local path (e.g., /path/to/repo), this is the default, and 
     --local is essentially a no-op. If the repository is specified as a URL, then this flag is 
     ignored (and we never use the local optimizations). Specifying --no-local will override the 
     default when /path/to/repo is given, using the regular Git transport instead. 

如果我正確地讀這篇文章,第二段說,此選項將默認爲上每當本地路徑,並給出了將只要給定的路徑不是本地的,就被忽略。那麼有什麼意義呢?它怎麼會有影響?當它做了一些事情時,它是否與舊版本的git兼容,基本上是沒有操作的存根?

+0

我知道「 - 本地」克隆回購和「 - 無本地」回報之間的一種不同效應。使用「 - local」它克隆搖擺的對象,但是「--no-local」它不會。 – ElpieKay

回答

4

這是泄漏的技術細節 - 實現--no-X選項的方式。不是單獨定義--no-local,而是選項--local,它是noop,但它有--no-*版本。同樣的方法(雖然沒有在幫助中提到),但您可以運行git clone --checkout ...,但它不會影響任何內容,因爲默認情況下克隆會檢出。

PS:some long time ago it was not a default,所以使用它確實有意義。

相關問題