git 不忽略目录,即使它在 .git 忽略文件中

git does not ignore directory even though it is in .gitignore file

git status 打印以下内容:

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   .gitignore
    new file:   app.js
    new file:   dev1/test.js
    new file:   dev2/test.js
    new file:   git
    new file:   log.txt

.gitignore 文件的内容:

   hell.txt
   /dev1

添加文件的全部内容后,连文件 hell.txtdev1 文件夹也被上传 还有运行记事本里的文件,没有编码问题 另外,我仔细检查了这个事实,首先我包含了 gitignore 文件,然后我包含了所有文件。

您已经上演了 dev1/test.js,这就是它不会被忽略的原因。使用 git reset HEAD dev1/test.js 取消暂存。