我是 git 的新手,我正在尝试 git add 我的整个工作目录,但我收到错误消息:
fatal: pathspec 'folder' did not match any files.
当我执行此命令时我在工作目录中,我做错了什么? 另外,提交整个文件夹而不是逐个文件提交是好习惯吗? 谢谢
最佳答案
我的猜测是,当您已经在 folder
中时,您正在尝试添加 folder
。
$ cd my_folder
$ git init
$ git add my_folder # this is not going to work
相反,添加文件夹中的所有内容,而不是文件夹本身:
$ cd my_folder
$ git init
$ git add .
对于您的其他问题,添加整个文件夹没问题,但仅在添加子 文件夹时才相关。同样,您不能 git add
作为您的存储库的文件夹(上面的 my_folder
)。
$ cd my_folder
$ ls
my_subfolder other_things
$ git add my_subfolder # this is fine
将工作树中的所有内容添加到存储库的常用方法是 git add .
。
关于git - 如何git添加整个文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44306606/