Git pre-commit钩子修复尾部空白
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Git pre-commit钩子修复尾部空白相关的知识,希望对你有一定的参考价值。
#!/bin/sh # # A git hook script to find and fix trailing whitespace # in your commits. Bypass it with the --no-verify option # to git-commit # if git-rev-parse --verify HEAD >/dev/null 2>&1 ; then against=HEAD else # Initial commit: diff against an empty tree object against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 fi # Find files with trailing whitespace for FILE in `exec git diff-index --check --cached $against -- | sed '/^[+-]/d' | sed -r 's/:[0-9]+:.*//' | uniq` ; do # Fix them! sed -i 's/[[:space:]]*$//' "$FILE" done # Now we can commit exit
以上是关于Git pre-commit钩子修复尾部空白的主要内容,如果未能解决你的问题,请参考以下文章
Vue+ESLint+Git钩子函数pre-commit配置教程