git - 为什么 git clone 有时创建一个 .git 目录,有时不创建?

前面至少有 3 个问题解释了如何在没有 .git 目录的情况下克隆存储库:

  • Do a "git export" (like "svn export")?
  • Git clone without .git directory
  • What's the best practice to "git clone" into an existing folder?

从这些问题来看,您似乎不能只运行 git clone 并在没有 .git 目录的情况下克隆存储库。

然而,在我克隆的大多数存储库中,例如下面命令中的存储库,没有创建 .git 目录。

git clone https://github.com/scotch-io/scotch-box.git

什么决定了一个直接的 git clone 命令是否创建了一个 .git 目录?

最佳答案

git clone 之后总是 .git 目录。没有异常(exception)。如果您没有看到它,那么它会被 stash (这如何发生取决于您的操作系统。Linux 上的 ls 不显示以点开头的文件/目录。您必须使用 ls -a.)

.git 目录是必不可少的,因为它包含 git 使用的所有文件和信息。

这是你提到的 git-clone 之后发生的事情:

/tmp % git clone https://github.com/scotch-io/scotch-box.git
Cloning into 'scotch-box'...
remote: Counting objects: 83, done.
remote: Total 83 (delta 0), reused 0 (delta 0), pack-reused 83
Unpacking objects: 100% (83/83), done.
Checking connectivity... done.
/tmp % cd scotch-box 
/tmp/scotch-box (git)-[master] % la
total 40K
drwxr-xr-x 4 t t 4.0K 12. Aug 14:10 .
drwxrwxrwt 8 root  root   12K 12. Aug 14:10 ..
drwxr-xr-x 7 t t 4.0K 12. Aug 14:10 .git
-rw-r--r-- 1 t t   18 12. Aug 14:10 .gitignore
-rw-r--r-- 1 t t 7.4K 12. Aug 14:10 README.md
-rw-r--r-- 1 t t  480 12. Aug 14:10 Vagrantfile
drwxr-xr-x 2 t t 4.0K 12. Aug 14:10 public

https://stackoverflow.com/questions/31964745/

相关文章:

javascript - 检查字符串的第一个字符是否为数字会报错,表明 charat 不是有效方法

python - 如果在 Python 中出现异常重试

r - 如何在 R 中以固定网格模式绘制 "matrix"

asp.net - ResponseMode ="File"不工作

php - Laravel 5.1 如何检查目录中是否存在文件?

python - Django 休息框架 : How serialize list of list?

c# - 使用 Prism 库将 View 注入(inject) TabControl

batch-file - 批处理文件中的时间戳未正确更新

Java - 编译器错误地解析 unicode 源文件

c# - 将浮点指针作为 IntPtr 传递(pinvoke)