gpt4 book ai didi

git - 为什么 "git clone"在传递本地文件:///url?时打包对象数据库

转载 作者:太空狗 更新时间:2023-10-29 14:15:55 25 4
gpt4 key购买 nike

以下描述了为重现观察到的行为而要执行的 bash 命令。虽然这些已经通过 msysgit 运行,但我怀疑在 *nix 环境中结果应该是相似的。

设置源存储库

$ mkdir main && cd main
$ git init .
Initialized empty Git repository in d:/temp/main/.git/
$ echo a > a.txt
$ git add . && git commit -m "Initial commit"
[master (root-commit) e1ec355] Initial commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 a.txt

使用本地文件克隆源存储库:///url

$ cd ..
$ mkdir clonefromfileurl && cd clonefromfileurl
$ git clone file:///d:/temp/main
Cloning into 'main'...
remote: Counting objects: 3, done.
Receiving objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0)

使用本地文件路径克隆源存储库

$ cd ..
$ mkdir clonefrompath && cd clonefrompath
$ git clone /d:/temp/main
Cloning into 'main'...
done.

根据 Wikipedia ,带有三重斜杠的文件 url 表示本地资源。

但是,当通过本地 file:/// url 克隆时,对象数据库在传输(复制?)之前被打包。当源存储库的位置表示为本地路径时,情况并非如此。

考虑到源代码库和目标代码库都托管在 localhost 上,为什么 git 会以不同的方式运行?

最佳答案

来自 git clone 手册:

For local repositories, also supported by git natively, the following syntaxes may be used:

  • /path/to/repo.git/
  • file:///path/to/repo.git/

These two syntaxes are mostly equivalent, except the former implies --local option.

因此,当您使用 file:/// 时,它并不意味着您必须明确添加的 --local 克隆。

关于git - 为什么 "git clone"在传递本地文件:///url?时打包对象数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8897556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com