9

I use Git pull to download changes from remote repo to my local dev folder. the problem is every time I pull changes, git downloads some file that exists in .gitignore file (e.g. /app/config/config.yml)

what am I doing wrong ?? here is my .gitignore

# Parameters
/app/config/parameters.yml
/app/config/parameters.ini
/app/config/config.yml

but when I pull git pull I find a new config.yml !!

2 Answers2

12

Check if your local config.yml is actualy ignored, or if it is currently versioned.

git check-ignore -v -- app/config/config.yml

If it isn't ignored, you need to remove from the index and record that deletion

git rm --cached -- app/config/config.yml
git commit -m "delete config.yml"
git push

Then the next pull wouldn't bring that file back.

But, as commented by Shichu Zhu, it also means the next git pull will, for other collaborator, will delete their local config.yml.
So you need to communicate that, for them to do something like this answer.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • If you remove & push, then collaborators' local config.yml will be deleted when they do a git pull. Need to be cautious this is expected outcome. – Shichu Zhu Jun 02 '18 at 06:11
  • @ShichuZhu Thank you. I have included your comment in the answer for more visibility. – VonC Jun 02 '18 at 06:18
10

.gitignore only ignores untracked files. It does not have any influence to the ones that have already been committed.

The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.

References:

zerkms
  • 249,484
  • 69
  • 436
  • 539