So I have a project with a submodule that gets updated every once in awhile. I have some rules for commits that I try to follow and one of them is to include the branchname in the commit. I accomplish this with githooks as follows:
From top level directory
.git/hooks/prepare-commit-msg
#!/bin/sh
BRANCH=`git branch | grep '^\*' | cut -b3-`
FILE=`cat "$1"`
echo "$BRANCH $FILE" > "$1"
.git/hooks/pre-commit
#!/bin/bash
find vendor -name ".git*" -type d | while read i
do
if [ -d "$i" ]; then
DIR=`dirname $i`
rm -fR $i
git rm -r --cached $DIR > /dev/null 2>&1
git add $DIR > /dev/null 2>&1
fi
done
Then I just set permissions sudo chmod 755 .git/hooks/prepare-commit-msg sudo chmod 755 .git/hooks/pre-commit
However, this does not work for the submodule as it does not have the .git directory. Is there a way to force the submodule to use the hook from the parent directory? If I open the submodule independently I can make it work however, it's alot more practical to keep it under the parent as it keeps stuff organized.