How to remove local (untracked) files from the current Git working tree?

git reset --hard只能删除tracked的工作区文件,未跟踪的貌似删不掉,我在stack overflowshang找到了一个答案:https://stackoverflow.com/questions/61212/how-to-remove-local-untracked-files-from-the-current-git-working-tree

As per the Git Documentation git clean

Remove untracked files from the working tree

Step 1 is to show what will be deleted by using the -n option:

git clean -n

Clean Step - beware: this will delete files:

git clean -f
  • To remove directories, run git clean -f -d or git clean -fd
  • To remove ignored files, run git clean -f -X or git clean -fX
  • To remove ignored and non-ignored files, run git clean -f -x or git clean -fx
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容