LogoDuyệtSr. Data Engineer
HomeAboutPhotosInsightsCV

Footer

Logo

Resources

  • Rust Tiếng Việt
  • /archives
  • /series
  • /tags
  • Status

me@duyet.net

  • About
  • LinkedIn
  • Resume
  • Projects

© 2026 duyet.net | Sr. Data Engineer | 2026-02-27

Git - Tutorial remove untracked files

Note: This post is over 11 years old. The information may be outdated.

If you have a bunch of untracked files and want to remove them all in one go then just do this:

$ git clean -f

Useful Options

Dry run - See what would be removed without actually deleting:

$ git clean -n

Remove untracked directories - Include directories in cleanup:

$ git clean -fd

Interactive mode - Choose which files to remove:

$ git clean -i

Force with directories - Remove both files and directories:

$ git clean -ffd

Important Notes

  • Untracked files are files that Git hasn't tracked yet (not in .gitignore, not staged, not committed)
  • Warning: git clean is destructive and cannot be undone. Always use -n (dry run) first to verify what will be deleted
  • Use git clean to clean up build artifacts, node_modules, logs, and other temporary files not tracked by Git
Aug 25, 2015·11 years ago
|Git|
Git
|Edit|

Related Posts

Git - 19 Tips For Everyday Git Use

I’ve been using git full time for the past 4 years, and I wanted to share the most practical tips that I’ve learned along the way. Hopefully, it will be useful to somebody out there

Sep 16, 2015·10 years ago
Read more

Git rebase, gộp commits bằng rebase

Trong dự án, code của bạn luôn có sự thay đổi, sau khi push 1 đống commit lên github. Một ngày kia ông Leader kêu lại: "Ê mày, sửa chỗ này, sửa chỗ kia, code không đúng chuẩn rồi, bla bla ...". Thế là phải hồi hì hục cải tiến code, coding style cho "chuẩn".

Aug 25, 2015·11 years ago
Read more

Git - Cách xóa nhanh tất cả các branch cũ đã merge vào branch master

Nếu bạn có rất nhiều branch trên repo, mỗi branch phát triển 1 chức năng của dự án. Trong số chúng có nhiều branch đã hoàn thành, và đã được merge vào branch chính (master) chẳng hạn, mình gọi các branch này là branch cũ.

Aug 25, 2015·11 years ago
Read more

Git - Cách xem nội dung 1 file ở branch khác

Nếu bạn đang ở 1 nhánh, và bạn muốn xem nội dung của 1 file nằm ở trên nhánh khác mà không cần phải checkout.

Aug 25, 2015·11 years ago
Read more
On this page
  • Useful Options
  • Important Notes
On this page
  • Useful Options
  • Important Notes