How to get tree -a to ignore .git directories?
7,047
Solution 1
You need to use the -I flag to exclude a pattern:
tree -a -I '.git'
Hope it helps.
Solution 2
I wrote a node based clone of tree called tree-fiddy that honors gitignore settings. It's pretty alpha right now, but it's working fine on my machines.
Solution 3
I was in the need to exclude .git
as well as .vendor
and didn't know how to specify multiple directories.
This works:
tree -a -I '.git|.vendor'
Related videos on Youtube
Author by
Oliver Salzburg
Updated on September 18, 2022Comments
-
Oliver Salzburg over 1 year
I love using
tree
to list directories, and I have a git repository with all my dotfiles. For me to be able to see them I need to dotree -a
, but that will also list the contents inside the.git
directory, which most people (myself included) never dare touching.How would I get
tree -a
to exclude only the.git
directory? -
Jon Bentley about 3 yearsFor this particular use you can shorten it to
tree -aI .git
-
Admin about 2 yearsVery interesting, because the intuitive
tree -a -I .git -I .vendor
is only taking the last one into account.