排除跟踪.gitignore不起作用

时间:2016-12-22 04:27:14

标签: git gitignore

我正在尝试删除“js”文件夹中的所有文件。

这是我的.gitignore:

# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp


# dependencies

# IDEs and editors
/.idea

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map

# js
js/


#System Files
.DS_Store

node_modules/
bower_components/
.sass-cache/
images/
app/test/reportscreenshots/
app/test/report/

请注意,js/不会删除该文件夹中的文件。这是我的文件夹结构:

enter image description here

为什么我的.gitignore不会排除“js”文件夹中的文件被跟踪?

1 个答案:

答案 0 :(得分:0)

如果之前已经跟踪过该文件夹,则将其添加到.gitignore并不会将其删除。

您还需要从git repo中删除文件/目录

git rm --cached -r mydirectory

--cached会将其从gitrepo中删除,但不会从服务器中删除。来自this StackOverflow question

之后,如果您git status,您将在状态中看到已删除的文件夹。您需要提交删除。