SheppLogan
SheppLogan

Reputation: 352

Gitignore config - how to make git aware

I configured git with:

git config --global core.excludesFile ~/.gitignore

I added new rules:

*.png *.h5 *.mat

each one on a different line (consecutive lines) then saved.

Then went to my git folder (with my source code, other files etc.). I do git add *, but git still wants to add h5 files!!. Do I have to do something else? How to make git aware of the new ignore rules before git add?

I have read that creating a .gitignore file and running the aforementioned command was enough to force git to be aware of the ignored files in a global way?

Upvotes: 1

Views: 452

Answers (1)

UsamaAmjad
UsamaAmjad

Reputation: 4604

You can remove the git cache and then add all files again

git rm -r --cached .

Add all files again

git add .

And then commit changes

git commit -m ".gitignore is now working"

Note: be aware to commit all your changes before, otherwise you will lose control on all the changed files

See here for more info

Upvotes: 2

Related Questions