DEV Community

Sekti Wicaksono
Sekti Wicaksono

Posted on • Edited on

Add tree to git-bash on Windows 10

Step-by-step

  1. Go to http://gnuwin32.sourceforge.net/packages/tree.htm
  2. Download the Binary version (see image below) Alt Text
  3. Open the zip file and double click to bin folder Alt Text
  4. Extract tree.exe to C:\Program Files\Git\usr\bin
  5. Try on your git-bash now. Result image

Credit:
https://superuser.com/questions/531592/how-do-i-add-the-tree-command-to-git-bash-on-windows/1141489#1141489

Top comments (3)

Collapse
 
bugb profile image
bugb • Edited

you can use

cmd //c tree
Enter fullscreen mode Exit fullscreen mode

no need to install anything

Collapse
 
xixianykus profile image
xixianykus

This works well for a basic listing of sub directories.

However the first method, using the Linux version, has a lot more options. Using tree -C adds colour making directories easier to visually separate from files. Using tree -L 2 will just go down 2 levels (or any number you use).

I couldn't get the Windows version to list out files from git-bash properly either using the /F switch.

Collapse
 
fouram profile image
fouram • Edited

Thank you for your post. But I would like to point out that gnuwin32 is a very old project and that there are good alternatives today. Since you can call commands from other CLIs from the GIT Bash, I suggest doing the same. Don't rely on old libraries.

You can use the CMD example already mentioned. My point is that the possibilities are not limited to CMD. You can also use powershell commands in GIT Bash instead. This is far more powerful.

powershell tree

In general i recommend the use of the Microsoft Windows Terminal.

The purpose of GIT Bash is not to emulate a Linux environment, but simply to use GIT. I hope it helps someone.

Cheers.