Git敏捷开发--reset和clean

reset

丢弃本地所有修改,强行和上游分支保持一致

git reset --hard HEAD

若仅丢弃某个文件的改动,利用checkout

git checkout your_file

clean

清除未跟踪文件。reset和checkout命令只能丢弃已经在git index里的文件

清除新增的文件或者文件夹

删除未跟踪文件 -f 即 -file的意思

git clean -f

连同删除未跟踪文件夹 -fd 即-file dir的意思

git clean -fd

在编译阶段,有时需要保持repo clean,清理.gitignore里的文件,可以加 -x

git clean -xfd

-n参数可以输出哪些文件将要被删除

git clean -nf
# 输出: Would remove your_file

猜你喜欢

转载自www.cnblogs.com/CocoML/p/12727288.html