git hooks All In One
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 发布文章使用:只允许注册用户才可以访问!
git hooks All In One的更多相关文章
- [git hooks] pre-commit 配置
在开发过程中,通常使用 eslint 来规范团队的代码风格.但是 eslint 只能在开发服务器启动的时候才去检验代码.如果一个人在不启动开发服务器的情况下,修改了代码直接提交到git,那么别人pul ...
- Git Hooks、GitLab CI持续集成以及使用Jenkins实现自动化任务
Git Hooks.GitLab CI持续集成以及使用Jenkins实现自动化任务 前言 在一个共享项目(或者说多人协同开发的项目)的开发过程中,为有效确保团队成员编码风格的统一,确保部署方式的统一, ...
- 使用Git Hooks实现开发部署任务自动化
前言 版本控制,这是现代软件开发的核心需求之一.有了它,软件项目可以安全的跟踪代码变更并执行回溯.完整性检查.协同开发等多种操作.在各种版本控制软件中,git是近年来最流行的软件之一,它的去中心化架构 ...
- 用 Git Hooks 进行自动部署
原文发表于 http://ourai.ws/posts/deployment-with-git-hooks/ 昨天开始接手开发公司前端团队的主页,在稍微修改点东西后推送到远程仓库想看下线上结果时发现并 ...
- 012-基于 git hooks 的前端代码质量控制解决方案
原文看这里:https://github.com/kuitos/kui...全部文章看这里 https://github.com/kuitos/kui... 国际惯例先说下故事背景 通常情况下,如果我 ...
- 通过Gradle Plugin实现Git Hooks检测机制
背景 项目组多人协作进行项目开发时,经常遇到如下情况:如Git Commit信息混乱,又如提交者信息用了自己非公司的私人邮箱等等.因此,有必要在Git操作过程中的适当时间点上,进行必要的如统一规范.安 ...
- [NPM] Run npm scripts with git hooks
In this lesson we will look about how we can integrate with git hooks to help enforce a certain leve ...
- 搭建Git服务器环境----Git hooks代码自动部署
引言:自己想搭一套git的服务端环境,不想用github码云等.经多方资料整合,实验总结,以下是亲测有效的方式.可用于公司日常开发 一.搭建Git环境 ① 安装 Git Linux 做为服务器端系统, ...
- 8.3 Customizing Git - Git Hooks
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks https://github.com/git/git/blob/master/temp ...
- 8.3 Customizing Git - Git Hooks 钩子 自动拉取 自动部署 提交工作流钩子,电子邮件工作流钩子和其他钩子
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks https://github.com/git/git/blob/master/temp ...
随机推荐
- MongoDB数据库的基本使用!
MongoDB数据库的基本使用! 1 进入mongoose数据库 在控制台中输入 mongo; 2 查看所有的数据库 show dbs; 3 查看当前数据库的名称 db; 4 查看数据库中的所有的表 ...
- 中文电子病历命名实体识别(CNER)研究进展
中文电子病历命名实体识别(CNER)研究进展 中文电子病历命名实体识别(Chinese Clinical Named Entity Recognition, Chinese-CNER)任务目标是从给定 ...
- Bitter.Core系列六:Bitter ORM NETCORE ORM 全网最粗暴简单易用高性能的 NETCore ORM 之 示例 DataTable 模型转换
当我们查询之前,我们先构造一个查询对象的输出DTO.如下图代码: public class TScoreSearchDto { /// <summary> /// 分数 /// </ ...
- Bitter.Core系列三:Bitter ORM NETCORE ORM 全网最粗暴简单易用高性能的 NETCore ORM 之 示例模型创建
在具体数据库操作之前,我们先准备好四张表以及相对应数据库操作模型: 学生表,年级表,班级表,学分表.示例数据库表,如下代码(MSSQL 为例) --学生表 CREATE TABLE t_student ...
- JavaFx ObservableList的使用详解
原文地址:JavaFx ObservableList的使用详解 | Stars-One的杂货小窝 最近在研究MVVM模式,发现可以将之前写的FxRecyclerView控件改造一下,便是开始尝试,尝试 ...
- C++ Primer Plus读书笔记(一)开始学习C++
1.using namespace std; 注意一下命名空间的概念,不编译这句话,可能就要用 std::cout << std::endl 这种写作方式了. 这句话放在函数内部,只对该 ...
- SpringCloud配置刷新机制的简单分析[nacos为例子]
SpringCloud Nacos 本文主要分为SpringCloud Nacos的设计思路 简单分析一下触发刷新事件后发生的过程以及一些踩坑经验 org.springframework.cloud. ...
- SpringBoot-Maven打包压缩瘦身
SpringBoot-Maven打包压缩瘦身 一.Spring Boot 可执行 jar 分析 1.1 打包 1.2 两种 jar 的比较 1.3 一次打包两个 jar 二.SpringBoot迭代发 ...
- Grafana Prometheus系统监控Redis服务
Grafana Prometheus系统监控Redis服务 一.Grafana Prometheus系统监控Redis服务 1.1流程 1.2安装redis_exporter 1.3配置prometh ...
- MySQL 数据库性能调优
MySQL 数据库性能调优 MySQL性能 最大数据量 最大并发数 优化的范围有哪些 存储.主机和操作系统方面: 应用程序方面: 数据库优化方面: 优化维度 数据库优化维度有四个: 优化选择: 数据库 ...