Created With

linkGit 清空工作目錄

在工作目錄中新增檔案之後,檔案會是未追蹤狀態,可用 clean 指令清空這些剛新增的檔案

清空檔案就是直接刪除檔案,不會把檔案移到資源回收桶

link檢視要被清空的檔案 -n

也就是列出所有未追蹤的檔案

1linkgit clean -n

link選擇要被清空的檔案 -i

1linkgit clean -i

執行上述指令會出現以下的訊息與選項

1linkWould remove the following items:

2link (一開始是所有)未追蹤的檔案清單

3link*** Commands ***

4link 1: clean 清空未追蹤的檔案清單

5link 2: filter by pattern 用規則篩選

6link 3: select by numbers 用編號選取

7link 4: ask each 逐項詢問

8link 5: quit 退出

9link 6: help 幫助

10linkWhat now>

以下是選 3 的情況

1linkWhat now> 3

2link 1: 檔案一 2: 檔案二

3linkSelect items to delete>> "編號"

4link * 1: 檔案一 2: 檔案二

5linkSelect items to delete>>

6linkWould remove the following item:

7link 檔案一

8link*** Commands ***

9link 1: clean

10link 2: filter by pattern

11link 3: select by numbers

12link 4: ask each

13link 5: quit

14link 6: help

15linkWhat now> 1

16linkRemoving 檔案一

link強制清空檔案 -f

就是刪除所有未追蹤的檔案

1linkgit clean -f

link清空檔案的狀態變化

步驟指令原狀態 > 新狀態
新增檔案copy NUL 檔名無 > 未追蹤
清空檔案git clean -i 或 -f未追蹤 > 無
Git 清空工作目錄檢視要被清空的檔案 -n選擇要被清空的檔案 -i強制清空檔案 -f清空檔案的狀態變化

技術筆記

準備chevron_right
HTMLchevron_right
CSS 基礎chevron_right
JS 基礎chevron_right
Git & GitHubchevron_right
CSS 進階chevron_right
Node.jschevron_right

返回個人網站