跳至主要內容

在 Git Bash 中使用 tree 命令

Loclinkgit原创小于 1 分钟约 248 字

在 Git Bash 中使用 tree 命令

概述:

在开发项目时经常需要在描述文档中展示项目的文件目录结构,以便查找文件。在大多数的 Linux 发行版中是自带 tree 命令的,而在 windows 中没有自带tree命令,所以我们可以通过 Git Bash 完成此操作。

安装 Tree for Windows

下载地址: Tree for Windowsopen in new window

  1. 进入页面后点击 Binaries 下载 Zip 压缩文件:

  1. 将其解压后得到 tree.exe 可执行文件:

image

  1. 将 tree.exe 文件移动至 git 安装目录下的usr/bin/目录下,例如我的路径为: D:/Program Files/Git/usr/bin

使用:

  1. 双击运行 tree.exe 文件

  2. 然后在 Git Bash 中执行 tree 命令(项目中):

tree -I '*svn|*node_module*'

-I 为忽略选项

打印出树形文件目录结构:

.
|-- README.md
|-- env.d.ts
|-- index.html
|-- package.json
|-- public
|   `-- favicon.ico
|-- src
|   |-- App.vue
|   |-- assets
|   |   `-- css
|   |       `-- base.css
|   |-- base-ui
|   |-- components
|   |-- main.ts
|   |-- router
|   |-- service
|   |-- store
|   `-- views
|-- tsconfig.config.json
|-- tsconfig.json
|-- vite.config.ts
`-- yarn.lock