git - 本地文件系统上的 git 存储库 Remote 是否应该以文件 ://? 为前缀

标签 git git-remote

如果我想为同一文件系统上的 git 存储库定义一个远程仓库,有人建议我应该以 file:// 为前缀。也就是说,

git remote add theremote file:///path/to/repo

我想知道仅使用是否有任何问题

git remote add theremote /path/to/repo

我快速检查了一下,git remote addgit clonegit pullgit 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 - 本地文件系统上的 git 存储库 Remote 是否应该以文件 ://? 为前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52259364/

相关文章:

git - `git fetch origin` 和 `git fetch git://127.0.0.1/` 有什么区别

git - 如何确定本地 Git 存储库最初从中克隆的 URL

git 相当于 'hg share' ?

ios - 多个开发人员在 iOS 中工作一个 Storyboard

git - 否定模式如何在 .gitignore 中工作?

git - git命令中的 'origin'和 'remote'有什么区别?

git - 检查 SSH key 的提交详细信息

Git post-checkout - 如果 Composer 安装失败如何拒绝推送

git - 为什么我会收到错误 : RPC failed; result=52, HTTP code = 0 fatal : The remote end hung up unexpectedly when pushing to github?

git - 如何更改远程 Git 存储库的 URI (URL)?