1

My project contains the following directories:

moduleA/jars/
moduleB/jars/
moduleC/jars/
...

I want git to ignore all those jars/ folders, so I created a .gitignore file with the following content:

**/jars

Then I commited & pushed everything to remote git repository. But I still see all those jars/ folders in remote git repository, why?

user842225
  • 4,825
  • 8
  • 48
  • 81

1 Answers1

0

First, if those folders are already committed, you need to remove them (from the Git repo, not from the disk, hence the --cached option):

find . -type d -name jars -print0 | xargs -0 git rm -r -f --ignore-unmatch

Second, to ignore a folder, its line in the .gitignore needs to ends with a '/'

jars/
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755