Created
January 9, 2012 21:43
-
-
Save harperreed/1585111 to your computer and use it in GitHub Desktop.
git_inotify-commit.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Originally by Bjoern Steinbrink, simplified by Johannes Schindelin | |
# http://git.661346.n2.nabble.com/inotify-commit-was-Re-git-guidance-td3534419.html | |
inotifywait -m -r --exclude ^\./\.git/.* \ | |
-e close_write -e move -e create -e delete . 2>/dev/null | | |
while read FILE_PATH EVENT FILE_NAME | |
do | |
FILE_NAME="$FILE_PATH$FILE_NAME" | |
FILE_NAME=${FILE_NAME#./} | |
# git doesn't care about directories | |
test -d "$FILE_NAME" && continue | |
case "$EVENT" in | |
*MOVED_TO*|*CREATE*) | |
git add "$FILE_NAME" | |
git commit -m "$FILE_NAME created" | |
;; | |
*CLOSE_WRITE*|*MODIFY*) | |
git add "$FILE_NAME" | |
git commit -m "$FILE_NAME changed" | |
;; | |
*DELETE*|*MOVED_FROM*) | |
git rm --cached "$FILE_NAME" | |
git commit -m "$FILE_NAME removed" | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment