Definitive retroactive .gitignore (how to make Git completely/retroactively *forget* about a file now in .gitignore)

EDIT: I’ve recently found git-filter-repo. It may be a better choice. Perhaps a good idea to investigate the rationale and filter-branch gotchas for yourself, but they wouldn’t have affected my use-case below. This method makes Git completely forget ignored files (past/present/future), but does not delete anything from working directory (even when re-pulled from remote). This … Read more

Why is git is ignoring files that aren’t in the .gitignore file?

git check-ignore Use git check-ignore command to debug your gitignore file (exclude files). For example: $ git check-ignore -v config.php .gitignore:2:src config.php The above output details about the matching pattern (if any) for each given pathname (including line). So maybe your file extension is not ignored, but the whole directory. The returned format is: <source> … Read more

git ignore exception

Use: *.dll #Exclude all dlls !foo.dll #Except for foo.dll From gitignore: An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources.

How do negated patterns work in .gitignore?

I think that what you actually want to do is: aaa/* !aaa/ccc You’re telling it “don’t look in aaa” so it never even examines the path aaa/ccc. If you use the wildcard, it still reads the contents of aaa, then each entry matches the wildcard and is ignored, except aaa/ccc which gets put back in.

Git – Creating a .gitignore file

Placement of .gitignore depends if the files need to be ignored for just one repo or for all your repos. For one repo, place it in the root of your repo. When you create a .gitignore file in an existing repo, or add files that were already in the repo, you have to make sure … Read more