Git pre-commit hook to prevent committing AWS keys
1 min readApr 18, 2018
This will guide you through a simple method to prevent you from committing aws keys into your repositories.
step 1 : Enable git templates
git config --global init.templatedir '~/.git-templates'
this will create a global git template directory
step 2 : Create a directory for global hooks
mkdir -p ~/.git-templates/hooks
This directory will hold the global hooks we need
step 3 : Write your hooks in ~/.git-templates/hooks
create a pre-commit file inside the hooks folder and paste the script given below
step 4 : Make sure the hook is executable
chmod a+x ~/.git-templates/hooks/pre-commit
step 5 : Re-initialize git in repo you want to use
git init
NOTE : This will not overwrite your previous hooks in local repo.
references : https://coderwall.com/p/jp7d5q/create-a-global-git-commit-hook