KexAri
KexAri

Reputation: 3977

.gitignore not ignoring specified folder

I'm trying to set up .gitignore but having issues. I have a directory flask-test that contains the sub directories app, tmp and flask. I want to ignore the flask directory. I init a new repository inside flask-test:

git init
git remote add origin https://github.com/username/flask-test.git

I then create the .gitignore:

sudo nano .gitignore

The contents of gitignore are like so:

flask

Is this correct? ^ or should it be flask/?

I then add, commit all the files and push:

git add .
git commit -m "First commit"
git push -u origin master

However when I check the repository the '.gitignore' file is not there. I then tried adding it after like so:

git add .gitignore
git commit -m "Adding gitignore" .gitignore
git push

Now this file is inside my repository however the flask directory is still there. What am I doing wrong?

Upvotes: 0

Views: 1243

Answers (1)

CodeWizard
CodeWizard

Reputation: 142552

If you wish to ignore folders you have to use the **.

For example if you wish to ignore the Debug & Release folder in any deepth:

**/Debug/
**/Release/

This will ignore any folder with this name regardless of the current location in the folder

Upvotes: 3

Related Questions