#!/bin/sh d=`pwd` while [ x"$d" != x"/" ] ; do if [ -d "$d"/.git ] ; then gitbase="$d" break fi d=`dirname "$d"` done if [ -z "$gitbase" ] ; then echo "Not a git repository -- aborting" >&2 exit fi d=`pwd` while [ x"$d" != x"/" ] ; do f="$d"/.gitignore test -f "$f" && sed -e "s@^\(!\)\?/@\\1$d/@" < $f if [ "$d" = "$gitbase" ] ; then break fi d=`dirname "$d"` done | sort | uniq | sed -e "s@^\(!\)\?${gitbase}@\\1@"