0

My .gitignore on a local repo looks like this:

api/includes/utility.php
api/includes/AppSettings.php

When I make changes to the above files, git seems to want me to track them and commit or else will not let me git pull

For example, on git status:

# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#   modified:   api/includes/utility.php

I have read several posts on Stack with similar issues, but I am not using wildcards in .gitignore.

dr_rk
  • 4,395
  • 13
  • 48
  • 74
  • 1
    Possible duplicate of [Making git "forget" about a file that was tracked but is now in .gitignore](http://stackoverflow.com/questions/1274057/making-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – Schwern Feb 09 '16 at 03:19
  • 2
    ["*A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected;*"](http://git-scm.com/docs/gitignore) – Schwern Feb 09 '16 at 03:20

1 Answers1

2

In this case, the file is already tracked; it cannot be truly ignored until it is "untracked". You can "untrack" it with git rm --cached api/includes/utility.php. Note that this will delete it on other people's machines when they do a git pull.

David Deutsch
  • 17,443
  • 4
  • 47
  • 54