使用git clone [path]命令时,--local参数是否会实际发挥作用?

3
根据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.

如果我理解正确,第二段意味着每当给出本地路径时,此选项将默认打开,并且在未指定本地路径时将被忽略。那么这有什么意义呢?它如何产生影响?它只是为了与旧版本的Git兼容而存在的一个无操作存根吗?

我知道“--local”克隆的仓库和“--no-local”克隆的仓库之间有一个不同的效果。使用“--local”会克隆悬空对象,但是使用“--no-local”则不会。 - ElpieKay
1个回答

4
这是泄露的技术细节 - 实现 --no-X 选项的方法。不是单独定义 --no-local,而是有一个无操作的 --local 选项,但它有一个 --no-* 版本。同样的方式(虽然没有在帮助中提到),你可以运行 git clone --checkout ...,但这不会影响任何东西,因为克隆默认会检出。
PS:很久以前它不是默认值,所以使用它是有意义的。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接