做外贸网站注意事项,网站备案 复查,烟台制作网站的公司,oa系统下载来自pauljz的答案适用于某些git钩子#xff0c;如pre-push#xff0c;但pre-commit无法访问这些变量oldrev newrev refname所以我创建了这个替代版本#xff0c;适用于预提交#xff0c;或者真正和钩子。这是一个pre-commit挂钩#xff0c;如果我们不在master分支上#…来自pauljz的答案适用于某些git钩子如pre-push但pre-commit无法访问这些变量oldrev newrev refname所以我创建了这个替代版本适用于预提交或者真正和钩子。这是一个pre-commit挂钩如果我们不在master分支上它将运行husky脚本。#!/bin/bash# git commit does not have access to these variables: oldrev newrev refname# So get the branch name off the headbranchPath$(git symbolic-ref -q HEAD) # Something like refs/heads/myBranchNamebranch${branchPath##*/} # Get text behind the last / of the branch pathecho Head: $branchPath;echo Current Branch: $branch;if [ master ! $branch ]; then# If were NOT on the Master branch, then Do something# Original Pre-push script from husky 0.14.3command_exists () {command -v $1 /dev/null 21}has_hook_script () {[ -f package.json ] cat package.json | grep -q \$1\[[:space:]]*:}cd frontend # change to your project directory, if .git is a level higher# Check if precommit script is defined, skip if nothas_hook_script precommit || exit 0# Node standard installationexport PATH$PATH:/c/Program Files/nodejs# Check that npm existscommand_exists npm || {echo 2 husky cant find npm in PATH, skipping precommit script in package.jsonexit 0}# Export Git hook paramsexport GIT_PARAMS$*# Run npm scriptecho husky npm run -s precommit (node node -v)echonpm run -s precommit || {echoecho husky pre-commit hook failed (add --no-verify to bypass)exit 1}fi我希望能有所帮助。您可以轻松修改if和fi语句之间的任何需求。