Skip to content

Instantly share code, notes, and snippets.

@abaqueiro
Created November 20, 2020 23:53
Show Gist options
  • Save abaqueiro/f4f6060d5cdbfa2a334a015e9a38075b to your computer and use it in GitHub Desktop.
Save abaqueiro/f4f6060d5cdbfa2a334a015e9a38075b to your computer and use it in GitHub Desktop.
Git Hooks

git-hooks

Some git hooks scripts that can be useful

#!/bin/bash
LOG=hook-post-commit.log
echo Commit was made $(date '+%Y-%m-%d %H:%M:%S') >> $LOG
echo -n "Detecting current branch: "
BRANCH_NAME=$(git symbolic-ref --short HEAD)
if [ $? -eq 0 ]; then
echo "$BRANCH_NAME"
echo git push origin "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
if [ $? -eq 0 ]; then
echo "[ OK ]"
fi
else
echo "ERROR, unable to detect current branch, detected: [$BRANCH_NAME]"
fi
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment