Skip to content

Instantly share code, notes, and snippets.

@FUT
Created November 24, 2014 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FUT/4cebdbd37602f8e81be1 to your computer and use it in GitHub Desktop.
Save FUT/4cebdbd37602f8e81be1 to your computer and use it in GitHub Desktop.
Git config for a project
#!/bin/bash
# This file applies all the git configs and hooks related to current repository
# Run it from Rails.root directory this way:
# ./dev/git/apply.sh
cp -v dev/git/pre-commit .git/hooks/pre-commit
cp -v dev/git/config .git/config
[push]
default = simple
[core]
whitespace=fix,-indent-with-non-tab,trailing-space,cr-at-eol
autocrlf=true
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[color]
ui = true
[color "diff"]
whitespace = red reverse
[remote "origin"]
url = git@github.com:expedite/expedite-rails.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
#!/bin/bash
# Checks the files to be committed for the presence of bad merges, debuger statmeents, etc,
# see FORBIDDEN for examples
# The array below can be extended for further checks
#add this into PROJECT_ROOT/.git/hooks/pre-commit
FILES_PATTERN='\.(rb|js|coffee)(\..+)?$'
FORBIDDEN=( binding.pry debugger '<<<<<<' '=======' '>>>>>>' )
FILES=$(git diff --name-only HEAD | grep -v pre-commit | grep -v README)
for i in "${FORBIDDEN[@]}"
do
for f in $FILES
do
grep $i $f && echo 'COMMIT REJECTED Found' $i 'in' $f 'Please remove them before commiting' && exit 1
done
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment