This project stores some git hooks that can help streamline working with multiple branches.
Pre push hooks were inspired by Colch's Git pre-push hook.
Currently there are the folling hooks available on this repository:
- prehook-push-denied.sh - denies push to the branches listed on no_push_branches variable;
- prehook-ask-confirmation.sh - asks for confirmation when pushing to the branches listed on confirm_branches variable.
- Enable git templates
git config --global init.templatedir '~/.git-templates'
- create a directory to hold the global hooks:
mkdir -p ~/.git-templates/hooks
- get one of the hooks available, and copy it to the templates directory. Make sure to apply the correct filename to the hook being copied (Check Githooks list). Example:
cp prehook-push-denied.sh ~/.git-templates/hooks/pre-push
- make it executable
chmod a+x ~/.git-templates/hooks/pre-push
- if you like to add it to an existing project just re-init it:
[projectdir]$ git init
This will not overwrite existing commits, or existing hooks. New projects will have the hook instaled by default.
- To remove it from a specific project, it has to be removed from the project's .git directory.
- add a hook variation that allows to only push merges to a group of branches (use
is_merge=$(git rev-parse -q --verify MERGE_HEAD)
).