Pav Sidhu
Pav Sidhu

Reputation: 6954

Gitignore does not ignore a subfolder

I have a directory like so:

.gitignore
myapp/
  instance/
  ...

And my .gitignore fire looks like this:

/myapp/instance

I would like the instance folder and its contents not to be pushed when committing however it always does. Why is this? Thanks.

Upvotes: 1

Views: 103

Answers (1)

paulsm4
paulsm4

Reputation: 121881

You have two problems:

1) In your .gitgnore, you should suffix your folder with "/": /myapp/instance/ (assuming "instance" is a folder)

2) If you've already committed stuff from that folder, you'll need to remove it as follows:

 git rm -r --cached . 
 git add .
 git commit -m 'Removed all files that are in the .gitignore' 
 git push origin master

Upvotes: 0

Related Questions