码迷,mamicode.com
首页 > 其他好文 > 详细

你可能不知道的git clean

时间:2017-05-11 00:59:02      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:rect   目录   构建   rem   ace   需要   操作   comment   示例   

git clean是干啥的?

git clean可以帮你清理workspace中未被git版本控制的文件,比如临时文件,构建出来的二进制文件。

使用方法

如果你的clean.requireForce项没有设置为false,那么每次使用git clean时都要加上-f参数

示例如下,workspace中有2个调试logo时创建的临时png文件,commit之前需要删掉。如果不用git clean的话需要一个一个rm。

LM-SHC-00355679@17:42:26:~/Angular/pomodoro-time (master)
=> git status -s
?? image/logo1.png
?? image/logo2.png

使用git clean可以快速清楚,当临时文件较多时尤其方便。

LM-SHC-00355679@17:42:30:~/Angular/pomodoro-time (master)
=> git clean -f
Removing image/logo1.png
Removing image/logo2.png

有的时候可能需要将当前workspace打包成zip。但是直接打包会将.gitignore里的文件也打进去。这是git clean也可以帮忙。只需加上-x参数。

LM-SHC-00355679@17:48:13:~/Angular/pomodoro-time (master)
=> cat .gitignore 
/coverage
LM-SHC-00355679@17:48:16:~/Angular/pomodoro-time (master) # -d 参数表示连同目录一起删除
=> git clean -xfd
Removing coverage/
LM-SHC-00355679@17:48:25:~/Angular/pomodoro-time (master)
=> ls coverage
ls: coverage: No such file or directory

以上就是git clean的基本用法啦。下面介绍下git clean的其他可选参数:

  • -n 并不实际执行删除操作,只显示出将被清理的文件列表
  • -X 仅删除.gitignore里标记过的文件,那些既不被git版本控制,又不在.gitignore中的文件会被保留。

你可能不知道的git clean

标签:rect   目录   构建   rem   ace   需要   操作   comment   示例   

原文地址:http://www.cnblogs.com/xuange306/p/6838964.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!