试图提交一个已经是git init的目录。接收“致命:不是git存储库(或任何父目录)”

时间:2014-06-29 16:11:35

标签: git github

我可以在目录中提交单个文件,但它不允许我提交整个目录。

1 个答案:

答案 0 :(得分:4)

您需要该文件夹中git commit才能正常工作 你需要先添加它

这不会起作用:

git init test
git add test
git commit -m "add test"

这样可行:

git init test
cd test
git add .
git commit -m "add test"

您可以检查文件夹是否为part of a repo

cd test
git rev-parse --git-dir

确保没有定义像GIT_DIR这样的环境变量(这会使git命令在其他地方查找git repo)