0

I have a problem with the file which is imported (application in django 1.11). After importing the file, the data is saved to it, its status is modified:

modified: media/import_file.json

Then I want to do a git pull on my code and I can not because the file is modified. I have entries in the .gitignore file, but they do not work:

/www/media/import_file.json
/www/media/*
user9192656
  • 549
  • 3
  • 16
  • can you share the git error message? – jan-seins Aug 02 '18 at 10:25
  • Possible duplicate of [How to make Git "forget" about a file that was tracked but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – phd Aug 02 '18 at 12:51

1 Answers1

3

The .gitignore is only looked up when we add files to repo. So, if the file was already added to git (using git add), just putting it in gitignore won't work. Once you add the file to .gitignore, you need to exclude it from the repository as well. It can be done using-

git rm --cached /www/media/import_file.json

Please make sure to add the --cached flag. It ensures that the file is removed from git repository only and not the file system.

priteshbaviskar
  • 2,139
  • 2
  • 20
  • 27