본문 바로가기
카테고리 없음

Git hook pre-commit

by BenKangKang 2021. 4. 16.
.git/hooks/prepare-commit-msg

#!/bin/sh BRANCH=`git branch | grep '^\*' | cut -b3-` FILE=`cat "$1"` echo "$BRANCH $FILE" > "$1"

.git/hooks/pre-commit

#!/bin/bash find vendor -name ".git*" -type d | while read i do if [ -d "$i" ]; then DIR=`dirname $i` rm -fR $i git rm -r --cached $DIR > /dev/null 2>&1 git add $DIR > /dev/null 2>&1 fi done

You can do it with a combination of the prepare-commit-msg and pre-commit hooks.

 

Set permissions

sudo chmod 755 .git/hooks/prepare-commit-msg

sudo chmod 755 .git/hooks/pre-commit

 

댓글