Skip to content

Instantly share code, notes, and snippets.

@thinkt4nk
Created November 30, 2011 21:43
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 thinkt4nk/1411055 to your computer and use it in GitHub Desktop.
Save thinkt4nk/1411055 to your computer and use it in GitHub Desktop.
git hook for resetting files before commit
#!/usr/bin/python
import os
import sys
ignore_paths = ['apps/ppc/templates/_scripts.php']
# chdir to project root
os.chdir(os.path.join(os.path.abspath(os.path.dirname(__file__)),'..','..'))
# for each path, reset and re-checkout before commit
for path in ignore_paths:
ignore_file = os.path.join(os.getcwd(),path)
print 'resetting file: %s' % ignore_file
if os.path.isfile(ignore_file):
print os.system('git reset %s' % path)
print os.system('git checkout %s' % path)
exit(0) # return zero status to continue commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment