how do I add the 'tree' command to git-bash on Windows?

Solution 1:

You could also use "cmd //c tree" to use Windows' tree

Explanation:

  • Launch cmd with '/c' argument and run tree, then terminate

/C Carries out the command specified by string and then terminates

(extra slash for escaping)

/a use to run with ascii chars in case it doesn't display right.

Answered in greater detail here: https://stackoverflow.com/q/515309/1261166

Solution 2:

I have downloaded the tree.exe inside the zip file from here http://gnuwin32.sourceforge.net/packages/tree.htm as suggested.

Then I have extracted the tree.exe file to C:\Program Files\Git\usr\bin (I have added this folder to windows path to make it work with the regular CMD but it works with GITBash too). Git Bash with tree command on windows

I hope this helps you somehow !

Solution 3:

There is a tree command in windows already — only problem is it is tree.com and git bash will not automatically add extension .com and execute it.

However it will find it if you press tab after you type tree or tre

To see files you have to use //f — you have to use // or bash will think it is folder name

I also used //a to show ascii lines but you don't have to use it

Example:

dean@dean:~/java$ tree
bash: tree: command not found

dean@dean:~/java$ tree.com //a
Folder PATH listing for volume c
Volume serial number is 4E70-B37A
C:.
+---atom
+---sublime
\---vscode

dean@dean:~/java$ tree.com //a //f
Folder PATH listing for volume c
Volume serial number is 4E70-B37A
C:.
+---atom
|       test1
|
+---sublime
|       test2
|
\---vscode
        test3

dean@dean:~/java$