Skip to content

Instantly share code, notes, and snippets.

@brycepj
Last active August 29, 2015 14:19
Show Gist options
  • Save brycepj/159255284dfd84fdb701 to your computer and use it in GitHub Desktop.
Save brycepj/159255284dfd84fdb701 to your computer and use it in GitHub Desktop.
#!/bin/bash
LINE=$(head -n 1 $1);
LENGTH=${#LINE};
if [[ $LENGTH -gt 50 ]]; then {
echo "Commit Aborted!";
echo -e "Message is \e[31m$LENGTH characters long\e[0m, must be <= 50."
exit 1;
} fi;
$ mkdir ~/.config/git
$ cp -r /usr/share/git-core/templates ~/.config/git/
$ git config --global init.templatedir ~/.config/git/templates/
$ wget https://gist.githubusercontent.com/CodeMan99/1ed7cc187f0e1c0a63bb/raw/9a50d3ae525d05eef1f083e6b87924d1a6ae1ec3/commit-msg
$ chmod 0755 commit-msg
$ mv commit-msg ~/.config/git/templates/hooks/
$ git init # do this in any repo where you want to add the new git hook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment