[英]How to remove all untracked git files/folders except the ignored ones?
[英]How to remove untracked files except the ones in .gitignore?
說我在不提交文件的情況下創建了一些文件進行實驗。 git status
顯示:
Untracked files:
(use "git add <file>..." to include in what will be committed)
file a
file b
nothing added to commit but untracked files present (use "git add" to track)
如果我運行git clean -f
,它將刪除文件a和b,以及其他未跟蹤的文件,例如node_modules
,tmp文件等,這些文件都包含在.gitignore
下。 是否有git命令僅刪除git status
下顯示的未跟蹤文件,還是我必須使用rm
手動刪除它們?
根據評論和相關問題 -默認情況下, git clean
不會刪除忽略的文件。 要包含它們,必須使用-x
(忽略的和非忽略的文件)或-X
(僅忽略的文件)。 但是,如果在.gitignore
下指定了一個類似folder_name/*
的模式,然后使用-d
選項,它也會刪除folder_name
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.