Trying to add a local .env file (which i added to the .gitignore) when i'm set on the master branch, but whenever i switch branches and come back, the file is gone. I do not want this file to be part of the repository, yet i'd like to see it in the editor across branches.
Asked
Active
Viewed 35 times
1 Answers
0
I think you will have to remove it from the history of the branches so that this doesn't nag you as you move between revisions where the file is and revisions where the file isn't.
If you checkout a revision where the file is (as in, it's part of the revision, it was tracked back then) and then you move to another where the file isn't anymore, git thinks "ok, this file has to go!" and it removes it.
If you rewrite the history of the branches (and add it to .gitignore from the first revision), then this won't happen again. Rewriting history is not something to take lightly, just in case.

eftshift0
- 26,375
- 3
- 36
- 60