根据git help clone
的输出,--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.
如果我正确读取此内容,则第二段说明只要给出本地路径,此选项将默认为on,并且只要给定路径不是本地路径,就会忽略该选项。那么重点是什么?它怎么能产生任何影响呢?它是否基本上是一个无操作的存根,以便在它执行某些操作时与旧版本的git兼容?
答案 0 :(得分:4)
这是泄露的技术细节 - 实现--no-X
选项的方法。不是单独定义--no-local
,而是选项--local
,它是noop,但它有--no-*
版本。同样的方式(虽然在帮助中没有提到)你可以运行git clone --checkout ...
但它不会影响任何东西,因为克隆默认检出。
PS:some long time ago it was not a default,所以使用它确实有意义。