首页 > 解决方案 > Git 已安装,但 .git 目录不存在,所以我无法配置它

问题描述

.git文件夹不存在

上个月相同的配置有 .git 目录

ls -la
total 97
drwxr-xr-x  24 root root  4096 Apr 19 09:22 .
drwxr-xr-x  24 root root  4096 Apr 19 09:22 ..
drwxr-xr-x   2 root root  4096 Apr 16 05:01 bin
drwxr-xr-x   4 root root  1024 Apr 16 05:03 boot
drwxr-xr-x  19 root root  3980 May 15 03:42 dev
drwxr-xr-x  92 root root  4096 May 17 02:58 etc
drwxr-xr-x   3 root root  4096 Apr 16 05:03 home
lrwxrwxrwx   1 root root    32 Apr 16 04:57 initrd.img -> boot/initrd.img-4.4.0-87-generic
drwxr-xr-x  22 root root  4096 Apr 16 05:01 lib
drwxr-xr-x   2 root root  4096 Apr 16 04:57 lib64
drwx------   2 root root 16384 Apr 16 04:57 lost+found
drwxr-xr-x   4 root root  4096 Apr 16 04:57 media
drwxr-xr-x   2 root root  4096 Aug  1  2017 mnt
drwxr-xr-x   2 root root  4096 Aug  1  2017 opt
dr-xr-xr-x 186 root root     0 May 15 03:42 proc
drwxr-xr-x   3 root root  4096 Apr 19 09:22 pub
drwx------   3 root root  4096 May 17 04:39 root
drwxr-xr-x  25 root root   920 May 17 02:58 run
drwxr-xr-x   2 root root 12288 Apr 16 05:03 sbin
drwxr-xr-x   2 root root  4096 Apr 29  2017 snap
drwxr-xr-x   2 root root  4096 Aug  1  2017 srv
dr-xr-xr-x  13 root root     0 May 17 02:59 sys
drwxrwxrwt   9 root root  4096 May 17 05:39 tmp
drwxr-xr-x  10 root root  4096 Apr 16 04:57 usr
drwxr-xr-x  14 root root  4096 Apr 16 05:02 var
lrwxrwxrwx   1 root root    29 Apr 16 04:57 vmlinuz -> boot/vmlinuz-4.4.0-87-generic

无法创建文件夹

标签: gitubunturoot

解决方案


如果您正在谈论该.gitconfig文件,那么它应该位于您的主目录下。该文件包含用户特定的配置。

当您运行时,该.git文件夹会在存储库中创建git init。它包含项目版本控制所需的所有信息。它还包含有关提交、远程仓库、地址等的信息。

请参阅文档

此命令创建一个空的 Git 存储库 - 基本上是一个包含、、和模板文件.git的子目录的目录。还会创建一个引用 master 分支的 HEAD的初始文件。objectsrefs/headsrefs/tagsHEAD


推荐阅读