https://github.com/log-oscon/git-hooks
https://github.com/log-oscon/git-hooks
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/log-oscon/git-hooks
- Owner: log-oscon
- Created: 2019-11-12T10:42:27.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-11-13T11:43:59.000Z (almost 6 years ago)
- Last Synced: 2025-04-08T06:37:07.860Z (7 months ago)
- Language: Shell
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Git hooks
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](https://gist.github.com/ColCh/9d48693276aac50cac37a9fce23f9bda).
## Available hooks
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.
## Install
* Enable git templates
```bash
git config --global init.templatedir '~/.git-templates'
```
* create a directory to hold the global hooks:
```bash
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](https://git-scm.com/docs/githooks)).
Example:
```bash
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.
## TODO
* 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)```).