ls_extensions_git
This function will display all file extensions (case-insensitive) of tracked files and their count in the given Git directory ($PWD
if not given) and its subdirectories.
This script, in conjunction with the ls_extensions script, is helpful in determining whether you have covered your files properly in your .gitattributes file.
|
1 | Both gradlew.bat and gradle-wrapper.jar have no attributes set—if we would add them to the Git index at this point they would not be handled properly by Git. |
2 | Add the appropriate attributes for JAR and Windows batch files. |
3 | Nothing has been added to the Git index yet: So ls_extensions_git shows no file extensions. |
4 | Add both files to the Git index. |
5 | Both file extensions will be reported once they are in the Git index. |
Usage
$ ls_extensions_git
5 sh
$ ls_extensions_git /tmp/example
3 txt
1 png
$ tree --noreport -a -I .git /tmp/example
/tmp/example
├── a.b.txt
├── a.txt
├── b.TXT
├── d
│ ├── .ignored
│ └── e.png
└── out.txt
$ git ls-files
a.b.txt
a.txt
b.txt
d/.ignored
d/e.png