if git status 1

if git status

if [[ -z $(git status -s) ]]
then
  echo "tree is clean"
else
  echo "tree is dirty, please commit changes before running this"
  exit
fi

Here is what the above code is Doing:
1. Check if the current directory is a git repository.
2. Check if the current git repository has any uncommitted changes.
3. If there are uncommitted changes, exit the script.

Similar Posts