2

I would like to ignore whole 'public' folder, I added this manually to my gitIgnore file, but still when I commit I can see things from this folder. How to do to file gitignore start ignore this?

My gitignore looks like this:

/vendor
/node_modules
.env
composer.lock
/public
/.idea
.phpstorm.meta.php
_ide_helper.php
npm-debug.log
package-lock.json
.gitattributes
Manuel Mannhardt
  • 2,191
  • 1
  • 17
  • 23
wenus
  • 1,345
  • 6
  • 24
  • 51
  • 2
    `git rm -r /public --cached`? – online Thomas Sep 19 '17 at 07:14
  • I don't want to remove this folder, I want to stop adding this all the time when I do commit – wenus Sep 19 '17 at 07:15
  • That is wat the `--cached` option is for – online Thomas Sep 19 '17 at 07:15
  • Duplicate of [this](https://stackoverflow.com/questions/7927230/remove-directory-from-remote-repository-after-adding-them-to-gitignore) and [this](https://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository). – Stefan Sep 19 '17 at 07:16
  • Possible duplicate of [Ignore files that have already been committed to a Git repository](https://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository) – phd Sep 19 '17 at 08:44

2 Answers2

5

The simplest way to do it:

  1. temporarily move out from repository the public folder.
  2. Do commit
  3. move it back. It will be ignored.
arku
  • 1,687
  • 17
  • 16
4

You can use -

git rm -r --cached <your file/directory Name>
online Thomas
  • 8,864
  • 6
  • 44
  • 85
Abhay Dixit
  • 998
  • 8
  • 28