# How can I check in a Bash script if my local Git repository has changes?

10/17 00:15

### 问题：

There are some scripts that do not work correctly if they check for changes.如果检查更改，有些脚本将无法正常工作。

I tried it like this:我是这样试的：

VN=$(git describe --abbrev=7 HEAD 2>/dev/null) git update-index -q --refresh CHANGED=$(git diff-index --name-only HEAD --)
if [ ! -z $CHANGED ]; then VN="$VN-mod"
fi


Is there some kind of boolean check if there has been changes since the last commit, or how can I really test if there are new changes to my local repository?是否有某种布尔检查自上次提交以来是否有更改，或者我如何真正测试本地存储库是否有新更改？

I'm doing all this for a version creation script (that I found somewhere here).我正在为版本创建脚本（我在此处找到的某个地方）执行所有这些操作。

0
0 收藏

0 评论
0 收藏
0