Administrator@WIN-O379IL963GN MINGW64 ~/Desktop/studygit (master)
$ git clone git@github.com:wanghuiwiki/git.git
Cloning into 'git'...
warning: You appear to have cloned an empty repository.
Administrator@WIN-O379IL963GN MINGW64 ~/Desktop/studygit (master)
$ git add .
error: 'Desktop/studygit/git/' does not have a commit checked out
fatal: adding files failed
Administrator@WIN-O379IL963GN MINGW64 ~/Desktop/studygit (master)
$ cd git
Administrator@WIN-O379IL963GN MINGW64 ~/Desktop/studygit/git (main)
$ git add .
warning: in the working copy of 'index.html', LF will be replaced by CRLF the next time Git touches it
如果当前目录的子目录中有
.git
文件夹,当你在当前目录执行git add .
时就会提示 "<filename> does not have a commit checked out"。你的
~/Desktop/studygit
目录本身就是一个 git 仓库(根据命令行提示符中的(master)
推断),然后你又在这个目录下克隆了一个仓库到子目录~/Desktop/studygit/git
中,所以这个子目录中包含.git
文件夹( git 仓库中一定会包含.git
文件夹,用来存储仓库信息)。因此在
~/Desktop/studygit
目录下执行git add .
会报错。参考:https://stackoverflow.com/a/5...