如果我想为同一文件系统上的 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).
关于git - 本地文件系统上的 git 存储库 Remote 是否应该以文件 ://? 为前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52259364/