Git pulls files in .gitignore

14,190

Solution 1

.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:

Solution 2

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.

Share:
14,190
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    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 !!