Skip to content

Instantly share code, notes, and snippets.

View LivesInSpb's full-sized avatar

Artem LivesInSpb

View GitHub Profile
@LivesInSpb
LivesInSpb / commit_if_changed.sh
Last active January 17, 2018 11:44 — forked from JamesSwift/commit_if_changed.sh
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.
#!/bin/bash
#cd /path/to/your/git/repo/
if [ "$(git status -s)" ] ; then
echo "Changes detected. Commiting."
git add .
git commit -am "Data time and who..."
else
echo "No changes detected. Commit canceled."
fi