git 清除未跟蹤的檔案

來源:互聯網
上載者:User

有時做Build會引入很多之前沒加入.gitignore的檔案。這時你不可能每個目錄每個檔案地去刪。

你要做的,git都幫你做好了。

hyang0@positive$  git --version
git version 1.7.4.1

git clean -df
可幫你搞定一切。

舉例:

git clean -dn  這個命令可以看看有哪此檔案和目錄會被刪

git clean -f 只會刪檔案,不會刪目錄

hyang0@positive$ 
git status
# On branch master
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#    deleted:    .gitignore
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    COPYING
#    INSTALL
#    Makefile.in
#    aclocal.m4
#    autom4te.cache/
#    config.h.in
#    configure
#    depcomp
#    install-sh
#    missing
no changes added to commit (use "git add" and/or "git commit -a")
hyang0@positive$ git clean -dn
Would remove COPYING
Would remove INSTALL
Would remove Makefile.in
Would remove aclocal.m4
Would remove autom4te.cache/
Would remove config.h.in
Would remove configure
Would remove depcomp
Would remove install-sh
Would remove missing
hyang0@positive$  git clean -df
Removing COPYING
Removing INSTALL
Removing Makefile.in
Removing aclocal.m4
Removing autom4te.cache/
Removing config.h.in
Removing configure
Removing depcomp
Removing install-sh
Removing missing
hyang0@positive$  git status
# On branch master
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#    deleted:    .gitignore
#
no changes added to commit (use "git add" and/or "git commit -a")

網址:http://hi.baidu.com/d_life/blog/item/c5ef6e82b3c424a76c811983.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.