Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History

readme.md

Outline

git hooks

$ cd ./.git && ls -al

$ cd ./hooks && ls -al
$ code ./pre-commit.sample
# OR
$ cat ./pre-commit.sample

$ vim ./pre-commit.sample
# ESC + :q, exit vim
# ESC + :!q, exit vim
$ vi ./pre-commit.sample
$ nano ./pre-commit.sample
# Control + X, exit nano

demo

rename pre-commit.sample => pre-commit.sh OR pre-commit

script 默认执行环境是 sh

  1. bash

pre-commit.sh OR pre-commit

#!/bin/sh
  1. perl

pre-commit.perl OR pre-commit

#!/usr/bin/perl

# 在 perl 的路径上可以加上 -w,可以显示程序中出现的一些警告
#!/usr/bin/perl -w

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

  1. python

pre-commit.py OR pre-commit

#!/usr/bin/python3 
# OR
#!/usr/bin/python

test

$ git add git-hooks/readme.md

$ gst
# -m ✅
$ git commit -m"python script"

# no message ❌
$ git commit
# Aborting commit due to empty commit message.

refs

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

https://github.com/web-full-stack/git/tree/main/git%20hooks

Morty Proxy This is a proxified and sanitized view of the page, visit original site.