https://github.com/archf/git-hooks
a shell script to manage user git hooks
https://github.com/archf/git-hooks
Last synced: over 1 year ago
JSON representation
a shell script to manage user git hooks
- Host: GitHub
- URL: https://github.com/archf/git-hooks
- Owner: archf
- Created: 2015-08-13T22:40:28.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-06-29T14:12:27.000Z (about 6 years ago)
- Last Synced: 2025-01-24T19:16:42.778Z (over 1 year ago)
- Language: Shell
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# git-hooks
A simple script to manage your hooks.
## Why do I need this?
Rerunning `git init` within an existing git repository will result in only
git 'templatedir' **new hooks** actually missing in `.git/hooks` to be added.
Thus, exising hooks are not updated!
You would have to manually delete a file to force a new copy into the git
repository. This script streamline this process.
## How does it work!
In this order
1. Lookup your `.gitconfig` for the `templatedir` parameter. You can retreive
current value using `git config --global init.templatedir` command. If
`templatedir` does exist, it will then look for hooks in
`/hooks/*`
2. For each file:
* a backup will be done in current repository `.git/hooks.old` if it already
exists in `.git/hooks`
* file `.git/hooks/` is updated
## Usage
run `git hooks` to show detected hooks in your configured `templatedir` as well
as the help menu.
```bash
GIT HOOKS
A custom git command to manage a git repository hooks.
See https://github.com/archf/git-hooks.
USAGE
git hooks [OPTIONS] CMD
OPTIONS
-h|--help Show this help menu.
-f|--force Force hook update.
CMD
show List git 'templatedir' available hooks.
install Install hooks found inside git 'templatedir' in repository.
Current hooks are backed up to '.git/hooks.old'. If the hook is
already found in '.git/hooks.old' it will be skipped unless you
delete it manually or use the --force option.
restore Restore previous set of hooks from '.git/hooks.old'.
help Show this help menu.
```
## FAQ
How to locate your current 'templatedir'?
```bash
git config --global init.templatedir
```
# Installation
Clone this repository somewhere and put this script in your PATH.
```bash
git clone git@github.com:archf/git-hooks.git
```
Personally I like to install those kind of scripts in
`~/bin` whilst `~/bin` is in your PATH.
Quickly add a symlink in `~/bin`:
```bash
make install
```