1. Go to .git/hooks
2. remove the word sample from the pre-push file
3. Add following code to detect console logs in files you want to push
console() { FILES_PATTERN='\.(js|coffee)(\..+)?$' FORBIDDEN='console.log' git diff --cached --name-only origin | grep -E $FILES_PATTERN | GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN | xargs echo && echo 'COMMIT REJECTED Found' $FORBIDDEN 'references. Please remove them before commiting' && exit 1 } console exit $?
Be First to Comment