Posts List

你可能不知道的git clean

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 仅删除.

你可能不知道的git rerere

rerere 是啥的缩写? rerere = reuse recorded resolution rerere是干啥用的? 它会让Git记住你是如何解决某个文件的两个版本之间的conflict,这样在下次Git遇到同样的文件在相同的两个版本间发生冲突时,可以自动帮你使用相同的方法解决冲突。 如何启用rerere? git config --global rerere.enabled true 或是 在repo目录里mkdir .git/rr-cache 不过推荐前者。 能举例说明吗? 参考inline的注释。 $ git init git-rerere-test Initialized empty Git repository in /cygdrive/e/test/git-rerere-test/.git/ $ cd git-rerere-test $ git config rerere.enabled true # 开启rerere功能 $ echo "What fruit do you like?" >> question $ git add . && git commit -m "initial drop" [master (root-commit) af9fdf9] initial drop 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 question $ git branch test # 创建test分支 $ echo "I like orange" >> question $ git add .