Skip to content

Instantly share code, notes, and snippets.

@oh-sky
Created April 17, 2014 14:03
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 oh-sky/10985890 to your computer and use it in GitHub Desktop.
Save oh-sky/10985890 to your computer and use it in GitHub Desktop.
.gitignoreに書いてあるけれどもインデックスされているファイルの一覧を取得する ref: http://qiita.com/oh-sky@github/items/fc91dc50967e020229ca
#!/bin/sh
GITIGNOREPATH=`git rev-parse --show-toplevel`'/.gitignore'
if [ $? -ne 0 ]
then
exit $?
fi
if [ ! -f $GITIGNOREPATH ]
then
echo $GITIGNOREPATH' does not exist.'
exit 1
fi
for indexed in `git ls-files`
do
for ignored in `cat ${GITIGNOREPATH} | grep -v '^#'`
do
if [ `echo /${indexed} | grep -F ${ignored}` ]
then
echo $indexed
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment