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

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

  •  31-05-2022
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top