gitignore does not ignore folder

In the root of my project I have a foo folder. Inside the foo folder I have a bar folder. I would like to ignore all changes to all files inside my bar folder. I have this in my gitignore:

/foo/bar

The folder is checked: it exists and it has the files to be ignored. gitignore is committed. However, I have a file where I make a moification and is inside my bar folder. When I type

  • Find git commits related to a certain part of a file
  • Git: How to convert an existing `merge` to a `merge --squash`?
  • Forge + Git + Laravel issue
  • How do I create a bare repo clone of existing git working repo
  • git gui branch management
  • Cannot push git repo to Dokku remote on Digital Ocean droplet?
  • git status
    

    inside my git bash I see the file which should have been ignored. What could be the reason and how can I successfully ignore all files inside my bar folder?

    Note, that the files were previously ignored with the same line, but I had to temporarily remove that line to commit something on the server. After the commit, I put back the line into the gitignore. This was a while ago, but now I have observed that the files will be in git status. I would expect to be able to modify the ignored files without they appearing in the git status.

  • Distributed Source Control is not for Visual Studio users?
  • Confusing error message from git
  • strip all timestamps from a local git repository
  • Prompt message before git pull
  • Git - Switching branches (windows) & uncommited changes
  • Git line number before and after
  • One Solution collect form web for “gitignore does not ignore folder”

    I’m guessing this folder has been checked into git before? Try running git rm --cached <folder> and check again.

    EDIT: The code had a little bug in it. The solution was:
    git rm -r --cached <folder>
    However, this answer has led me to the solution, so I will accept it.

    UPDATE: The -r is required.

    Git Baby is a git and github fan, let's start git clone.