Created
September 5, 2013 11:13
-
-
Save tadas-s/6448825 to your computer and use it in GitHub Desktop.
A small bash script function to check if local git repository copy has changes. I use it for some deployment automation scripts.
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 | |
# | |
# Checks if git repository at $1 does not have modified files | |
# | |
function is_dirty { | |
GIT_DIR="$1/.git" GIT_WORK_TREE="$1" git diff --quiet | |
if [[ $? == 0 ]]; then | |
return 1 | |
else | |
return 0 | |
fi | |
} | |
# usage example | |
is_dirty $1 && echo "$1 is dirty!" && exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment