git hooks All In One

$ xgqfrms git:(main) cd .git/
$ .git git:(main) ls
COMMIT_EDITMSG HEAD branches description index logs packed-refs
FETCH_HEAD ORIG_HEAD config hooks info objects refs
$ .git git:(main) cd hooks
$ hooks git:(main) ls -al
total 112
drwxr-xr-x 14 xgqfrms-mbp staff 448 Dec 7 00:01 .
drwxr-xr-x 16 xgqfrms-mbp staff 512 Dec 26 21:29 ..
-rwxr-xr-x 1 xgqfrms-mbp staff 478 Dec 7 00:01 applypatch-msg.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 896 Dec 7 00:01 commit-msg.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 4655 Dec 7 00:01 fsmonitor-watchman.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 189 Dec 7 00:01 post-update.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 424 Dec 7 00:01 pre-applypatch.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 1643 Dec 7 00:01 pre-commit.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 416 Dec 7 00:01 pre-merge-commit.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 1348 Dec 7 00:01 pre-push.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 4898 Dec 7 00:01 pre-rebase.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 544 Dec 7 00:01 pre-receive.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 1492 Dec 7 00:01 prepare-commit-msg.sample
-rwxr-xr-x 1 xgqfrms-mbp staff 3635 Dec 7 00:01 update.sample

pre-commit

$ code pre-commit.sample

#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit". if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi # If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii) # Redirect output to stderr.
exec 1>&2 # Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name. This can cause problems if you want to work with people on other platforms. To be portable it is advisable to rename the file. If you know what you are doing you can disable this check using: git config hooks.allownonascii true
EOF
exit 1
fi # If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --

husky

refs

https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

https://git-scm.com/docs/githooks

https://www.atlassian.com/git/tutorials/git-hooks

husky

https://www.cnblogs.com/xgqfrms/p/11650177.html



xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


最新文章

  1. EBS 追前台最后一个执行的sql
  2. .NET开发问题汇总
  3. 企业Openvpn环境部署
  4. 20150608_Andriod 发布问题处理
  5. POJ1947 - Rebuilding Roads(树形DP)
  6. android 判断程序是首次(第一次)进入
  7. Centos6.4安装JDK
  8. hdu 4679 (树形DP)
  9. Jquery结合datagrid框架
  10. 51nod 1595 回文度 | 马拉车Manacher DP
  11. win7 64位wamp2.5无法启动MSVCR110.DLL丢失听语音
  12. 【BZOJ3140】消毒(二分图匹配)
  13. FORM的静态提交
  14. lease.go
  15. C#调用Oracle的存储过程时,连接字符串需要配置PLSQLRSet=1
  16. UIButton设置UIControlContentHorizontalAlignment调整文字对齐方式
  17. Jquery操作ul的一些操作笔记
  18. 默认约束(DEFAULT)
  19. VS2013 &quot;当前不会命中断点.还没有为该文档家在任何符号&quot; 解决办法
  20. 【nginx,apache】thinkphp ,laravel,yii2开发运行环境搭建

热门文章

  1. 炸裂!MySQL 82 张图带你飞
  2. 处理K8S PVC删除后pod报错
  3. jQuery 实现复制功能
  4. git database 数据库 平面文件 Git 同其他系统的重要区别 Git 只关心文件数据的整体是否发生变化,而大多数其他系统则只关心文件内容的具体差异 Git 的设计哲学
  5. Redis下载及安装(windows版)
  6. 洛谷 P1401 城市
  7. Spring整合SpringMVC + Mybatis基础框架的配置文件
  8. 你真的知道为什么要使用void(0)代替undefined吗?
  9. SpringBoot使用SpringDataJPA完成CRUD
  10. SSH 登录警告:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!