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

问题:

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).我正在为版本创建脚本(我在此处找到的某个地方)执行所有这些操作。


解决方案:

参考一: https://en.stackoom.com/question/La8R
参考二: https://stackoom.com/question/La8R
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章