Git & Github
git hook: 특정 명령어 금지 시키기
taltal
2024. 1. 20. 18:03
728x90
반응형
.git/hooks 디렉토리에 pre-push를 만들어서
git push 명령어 전에 다음 로직을 선행시켜서 git push upstream master를 막아보자
$ cd .git/hooks
$ nano pre-push
아래 스크립트 작성
#!/bin/sh
remote="$1"
while read local_ref local_sha remote_ref remote_sha
do
if [ "$remote" = "upstream" ] && [ "$remote_ref" = "refs/heads/master" ]; then
echo "Pushing to upstream master is prohibited."
exit 1
fi
done
exit 0
pre-push 실행권한 주기
$ chmod +x pre-push
728x90
반응형