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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章