Skip to content

Instantly share code, notes, and snippets.

@Maki-Daisuke
Created November 6, 2013 13:03
Show Gist options
  • Save Maki-Daisuke/7335735 to your computer and use it in GitHub Desktop.
Save Maki-Daisuke/7335735 to your computer and use it in GitHub Desktop.
コメントのとおりですが、コミット用にステージされていないファイルの変更や、Gitの管理下におかれていないファイルがあると、コミットを拒否する pre-commit スクリプトです。 ちょっと厳しすぎる気もしますが……
#!/bin/sh
#
# A simple script to reject commit when there is an unstaged changes
# or an untracked file.
#
# To enable this script, copy this into .git/hooks in your working dir.
if `git status |grep -q 'Changes not staged for commit:'`
then
echo '[!!ERROR!!] Threre is a modified but unstaged file!'
exit 1;
fi
if `git status |grep -q 'Untracked files:'`
then
echo '[!!ERROR!!] There is an untracked file!'
exit 1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment