Skip to content

Instantly share code, notes, and snippets.

@matsuhisa
Last active August 29, 2015 14:22
Show Gist options
  • Save matsuhisa/364306abcda663331315 to your computer and use it in GitHub Desktop.
Save matsuhisa/364306abcda663331315 to your computer and use it in GitHub Desktop.
git commit する前にコンフリクトの残りがないかチェックする ref: http://qiita.com/matsuhisa_h/items/0b9de2ef534807065e54
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# コンフリクトしたファイルを探す
# 該当のファイルは、赤文字で表示(Macで確認)
for FILE in `git diff-index --name-status $against | grep -E '\.*$' | cut -c3-`; do
grep_result=`grep -E '(<<<<<<<|>>>>>>>)' $FILE | grep -v '^$'`
if [ -n "${grep_result}" ]
then
echo $'\e[1;31m'$FILE$'\e[m' ' <- コンフリクトの対応がのこっています'
echo $grep_result
exit 1
fi
done
@matsuhisa
Copy link
Author

=======

もいるのかも

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment