このロジックを bash スクリプトに組み込みたい: 現在のリポジトリにローカルの変更がある場合に処理を停止します。
私は git にも同じロジックを持っています。
#!/bin/bash
set -ex
git pull
git update
# Disallow unstaged changes in the working tree
if ! git diff-files --check --exit-code --ignore-submodules -- >&2
then
echo >&2 "error: you have unstaged changes."
exit 1
fi
# Disallow uncommitted changes in the index
if ! git diff-index --cached --exit-code -r --ignore-submodules HEAD -- >&2
then
echo >&2 "error: your index contains uncommitted changes."
exit 1
fi