Search code examples
gitgitignore

exclude from tracking with .gitignore not working


I'm trying to remove all files in "js" folder from being tracked.

Here is my .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/

Note the js/ it is not removing files in that folder from being tracked. Here is my folder structure:

enter image description here

Why does my .gitignore not exclude files in "js" folder from being tracked?


Solution

  • If the folder was already tracked before, adding it to .gitignore won't untracked it.

    You will also need to remove the file/directory from your git repo

    git rm --cached -r mydirectory

    --cached will remove it from gitrepo but not from the server. From this StackOverflow question

    After that, if you git status, you will see the deleted folder in the status. You will need to commit your deletion.