if i forget igonore a file before pusing a project, what should i do.?
I have an already initialized Git repository that I added a .gitignore file to. How can I refresh the file index so the files I want ignored get ignored?
if i forget igonore a file before pusing a project, what should i do.?
I have an already initialized Git repository that I added a .gitignore file to. How can I refresh the file index so the files I want ignored get ignored?
"How do I make Git forget about a file that was tracked, but is now in .gitignore?" address the main points:
git rm --cached -- file-which-should-be-ignored
If your .gitignore
was already set to ignore that file, said file will be ignored as soon as it is deleted (from the perspective of Git)
But removing the file from past commits is mentioned using the old git filter-branch
command.
Nowadays, git filter-repo
is recommended (to be installed first), using path-based filtering:
git filter-repo --invert-paths --path 'path/to/file/to/ignore'