git 清除未跟踪的文件

来源:互联网 发布:电通安吉斯网络测评 编辑:程序博客网 时间:2024/05/19 05:37

有时做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



原创粉丝点击