I put a file that was previously being tracked by Git onto the .gitignore list. However, the file still shows up in git status after it is edited. How do I force Git to completely forget the file?
The .gitignore will prevent untracked files from being added (without an add -f) to the set of files tracked by Git. But if you ever want to see that file again, git rm –cached file> — will continue to track any files that are already being tracked. Updated Answer in 2024 Do NOT re-apply to a local machine, which removes it from GitHub and deletes the file locally, but delete it on your local file file by Konstantin. Shortly use the answer: \’git update-index — — t-worktree-file –\n\nFor example, users often use the assume-unchanged and skip-worktree bits to tell Git to ignore changes to files that are tracked; this is not the case, as Gito may still check working tree files against the index when doing some operations; in general, GiT does not provide a mechanism to prevent changes in tracked files.\n\nHence, you should still use the original answer below. Original Answer WARNING: This will remove the physical file from your local machine and other developers\’ machines on your or their next git pull. To stop tracking a file, we have to remove it from the index: gg rm –cached file>.\n\nto recursively delete a folder and all files in the folder: git rm -r –cached folder> .\n\nThe file will be deleted from the head revision of the file on the next commit.