Created
August 3, 2012 11:32
-
-
Save JamesSwift/3246823 to your computer and use it in GitHub Desktop.
Sometimes you want to run an automated "git commit -a" (perhaps as a cron job), but you don't want to clog up your history if nothing has changed. I use the following script to run a commit only if changes have been made.
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/bash | |
cd /path/to/your/git/repo/ | |
if [ "$(git status -s)" ] ; then | |
echo "Changes detected. Commiting." | |
git add . | |
git commit -am "Your explanation here" | |
else | |
echo "No changes detected. Commit canceled." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment