簡體   English   中英

如何刪除.gitignore中的文件以外的未跟蹤文件?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM