Finding out which files are version controlled that now match the current .gitignore

StackOverflow https://stackoverflow.com/questions/17000338

  •  31-05-2022
  •  | 
  •  

Domanda

My organization made plenty of mistakes early on with git (storing binary objects, etc). We have re-done our .gitignore strategy to prevent binary objects (dll's, jars, zips) etc. from being committed.

What is the best way to identify files that are are currently version controlled, that would no longer be version controlled under the newly created .gitignore?

È stato utile?

Soluzione

I would use ls-files:

git ls-files -i --exclude-standard

This shows committed files that would be ignored by standard git rules (i.e. according to .git/info/exclude, .gitignore in each directory, and the user’s global exclusion file).

If you want to test a particular ignore file, you can use the -X parameter to specify the file:

git ls-files -i -X .\.gitignore
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top