Git stash 技巧
Git stash常用技巧
- git stash save
- git stash list
- git stash apply
- git stash pop
- git stash show
- git stash clear
- git stash drop
可配置的stash: git stash save
類似於git stash,但git stash 預設儲存到最上面,且沒有資訊,但這個命令可以配置一些有用的選項,以提高效率:
- 帶訊息存放
git stash save <stash_message>
- 儲存沒有追蹤的檔案
git stash save -u
或者
git stash save --include-untracked
顯示列表: git stash list
檢視所有stash資訊,按照時間順序最近的會放在最上面:
git stash list
使用stash且不刪除: git stash apply
通過stash id應用某個stash到專案中,且不會被刪除:
git stash apply <stash_id>
使用stash且刪除: git stash pop
通過stash id應用某個stash到專案中,且會被刪除:
git stash pop <stash_id>
顯示stash差異: git stash show
通過stash id檢視顯示差異總結,預設不寫id則只和最近的stash比較
git stash show <stash_id>
若想檢視具體差異:
git stash show -p
全部刪除stash: git stash clear
刪除倉庫中建立的所有stash
刪除某個stash: git stash drop
通過stash id 刪除工作棧中最近的stash,預設不寫id則只刪除最近的stash記錄
git stash drop <stash_id>