WebQube
WebQube

Reputation: 8981

failed to add a file to gitignore

I have a file I have to be ignored by git I have done this actions

  1. git rm --cached path_to_file/filename.py
  2. added path_to_file/filename.py to .gitignore

The file does not show up on git indeed but when I switch branches or even switch back to the original branch, the file is gone.

Upvotes: 1

Views: 45

Answers (1)

VonC
VonC

Reputation: 1328202

The thing is: git rm --cached path_to_file/filename.py would have worked even if the file was not present in the workspace (but was tracked by git)

So if you don't see that file after the git rm --cached step, that means it was deleted.
If you restore it and it does remain when switching branch, that means it is untracked (you can check that with git check-ignore -v -- path_to_file/filename.py)

Upvotes: 1

Related Questions