Jump to content

my .gitignore file is being ignored - Why?


OrganizedFellow
 Share

Recommended Posts

I have created my .gitignore file at the root, alongside my .git folder.

But when I run $git status it shows modified: .gitignore

And beneath that, it shows the files that have been modified and are supposed to be ignored.

I've looked on StackOverflow earlier but couldn't find anything that worked.

Here's the content of my file:

/site/assets/cache/*
site/assets/cache/*
site/assets/cache/
/site/assets/sessions/*
site/assets/sessions/*
site/assets/sessions/
/site/assets/logs/*
site/assets/logs/*
site/assets/logs/
/site/config.php
site/config.php
project.sublime-workspace
project.sublime-project
Link to comment
Share on other sites

The .gitignore file itself is being shown as modified because you've probably added it to the git index at some point - either directly using "git add .gitignore" or perhaps as part of a larger add - and then a git commit (or a "git commit -a ..."). That's OK if the .gitignore file is meant to be part of your project. Anyway, if that's the case then git is correctly letting you know about a change to the .gitignore file since the last commit you made.

However, I'm not sure why other files that it's meant to be excluding are showing as modified.

Got to run. Will post later if something comes to me.

Link to comment
Share on other sites

@OrganizedFellow,

Question: Did you start off without a .gitignore file in your project root and add it at a later date? Possibly after an initial add and commit on your project? If so, git will continue to track what is already in the index - regardless of the content of your .gitignore file. More details here.

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...