git生成文件目錄樹及日誌打印

@(git經常使用命令操做)node

如何用git生成一個文件目錄樹

由於Git-Bash中不支持tree命令,全部須要給Window平臺下Git-Bash添加tree命令linux

參考 https://www.jianshu.com/p/32ba82d84680git

下載 tree 命令的二進制包,安裝 tree 命令工具;

  1. 打開進入 Tree for Windows 頁面,選擇下載 Binaries zip 文件;
  2. 解壓壓縮包,找到壓縮包內的 bin 目錄,將 bin 目錄下的 tree.exe 複製;
  3. 找到 C:\\Program Files\Git\usr\bin 目錄,將 tree.exe 粘貼到該目錄下,安裝即完成;
    ## 測試 tree 命令
  4. 進入 Git-Bash,輸入 tree -L 1 命令,若是安裝成功,命令能夠正常執行。tree展現
  5. tree -L 5 -I "node_modules|dist|dist.zip" >tree.txt 將目錄結構導出數據庫

    經常使用指令

    tree -d 只顯示文件夾;
    tree -L n 顯示項目的層級。n表示層級數。好比想要顯示項目三層結構,能夠用tree -l 3;
    tree -I pattern 用於過濾不想要顯示的文件或者文件夾。好比你想要過濾項目中的node_modules文件夾,能夠使用tree -I "node_modules",過濾多個用 | 隔開 ,好比 tree -I "node_modules|dist"
    tree > tree.md 將項目結構輸出到tree.md這個文件。json

更多命令參考 https://wangchujiang.com/linux-command/c/tree.htmlapi

目錄結構顯示

├── README.md 項目描述
├── app  業務側代碼
│   ├── controller 與路由關聯的api方法
│   └── modal 數據模型
├── app.js 入口文件
├── bin nodemon
│   ├── run  nodemon 的入口文件
│   └── www
├── config 配置文件
│   ├── dbConfig.js 數據庫配置
│   ├── logConfig.js 日誌配置 
│   └── serverConfig.js 服務配置
├── logs  日誌目錄
│   ├── error 錯誤日誌
│   └── response 普通響應日誌 (還能夠繼續拆分,系統日誌,業務日誌)
├── middleware  中間件
│   └── loggers.js  日誌中間件
├── public
│   └── stylesheets 公用文件
├── routes  路由
│   ├── allRoute.js 總路由配置
│   ├── files.js 各個模塊路由配置
│   ├── index.js
│   └── users.js
├── uploads 上傳文件夾
│   └── 2017-8-29
├── utils 公用方法
│   ├── logUtil.js 
│   └── mkdir.js
├── views 頁面層
│   ├── error.jade
│   ├── index.jade
│   └── layout.jade
└── package.json


tree 目錄生成命令

tree -L 3 -I "node_modules"

Git如何打印出指定格式log

輸出指定格式的日誌信息

git log --graph --after="1 week ago" --oneline --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset - %Cgreen(%ad) %C(yellow)%d%Creset %s ' --abbrev-commit
在這裏插入圖片描述
--graph 圖像化顯示日誌操做
--after="1 week ago" 顯示一週前的日誌信息
--after="2018-12-3" --before="2018-12-7" 獲取該時間段內的日誌信息
--oneline 日誌信息顯示在一行
--author="tom" 篩選出做者提交的日誌
--date=format:'%Y-%m-%d %H:%M:%S' 設置日期顯示格式
--pretty=format: 設置日誌顯示格式
%h 提交對象的簡短哈希字串
%ad 做者修訂日期(能夠用-date= 選項定製格式)
%ar 做者修訂日期,按多久之前的方式顯示
%s 提交說明
%Cred 切換到紅色
%Cgreen 切換到綠色
%Cblue 切換到藍色
%Creset 重設顏色
-- >f:/work/worklog/log.log 將文件導出到指定文件ruby

更多命令參考 https://ruby-china.org/topics/939app

將日誌導出到指定目錄

git log --graph --after="1 week ago" --oneline --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%Cred%h%Creset - %Cgreen(%ad) %C(yellow)%d%Creset %s ' --abbrev-commit -- >f:/work/worklog/log.log工具

給命令設置別名

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --"
經過 git lg 進行調用
## Git打印退出命令
q 退出打印

參考 https://blog.csdn.net/liangxiaozhang/article/details/7903861

相關文章
相關標籤/搜索