git 本地文件系统上的远程存储库是否应该以 file:// 为前缀?
Should git repository remotes on the local filesystem be prefixed with file://?
如果我想为同一文件系统上的 git 存储库定义远程,有人向我建议它应该以 file://
为前缀。也就是说,
git remote add theremote file:///path/to/repo
我想知道使用
是否有任何问题
git remote add theremote /path/to/repo
我快速检查了一下,git remote add
、git clone
、git pull
和 git push
似乎都对更简单的选项感到满意。
是否存在缺少 file://
前缀会导致问题的情况?
Git 可以很好地处理本地路径。没必要用file://
,虽然有细微差别(引用自the documentation):
Git operates slightly differently if you explicitly specify file://
at the beginning of the URL. If you just specify the path, Git tries to use hardlinks or directly copy the files it needs. If you specify file://
, Git fires up the processes that it normally uses to transfer data over a network, which is generally much less efficient. The main reason to specify the file://
prefix is if you want a clean copy of the repository with extraneous references or objects left out — generally after an import from another VCS or something similar (see Git Internals for maintenance tasks).
如果我想为同一文件系统上的 git 存储库定义远程,有人向我建议它应该以 file://
为前缀。也就是说,
git remote add theremote file:///path/to/repo
我想知道使用
是否有任何问题git remote add theremote /path/to/repo
我快速检查了一下,git remote add
、git clone
、git pull
和 git push
似乎都对更简单的选项感到满意。
是否存在缺少 file://
前缀会导致问题的情况?
Git 可以很好地处理本地路径。没必要用file://
,虽然有细微差别(引用自the documentation):
Git operates slightly differently if you explicitly specify
file://
at the beginning of the URL. If you just specify the path, Git tries to use hardlinks or directly copy the files it needs. If you specifyfile://
, Git fires up the processes that it normally uses to transfer data over a network, which is generally much less efficient. The main reason to specify thefile://
prefix is if you want a clean copy of the repository with extraneous references or objects left out — generally after an import from another VCS or something similar (see Git Internals for maintenance tasks).