What's an easy way to detect modified files in a Git workspace?

前端 未结 5 1277
别那么骄傲
别那么骄傲 2021-01-01 09:04

During make, I create string fields which I embedded in the linked output. Very useful.

Other than a complex sed/grep parsing of the

5条回答
  •  醉话见心
    2021-01-01 09:16

    For git hooks, I found this command useful

    git diff-index --exit-code --ignore-submodules HEAD
    

    For example

    //run some static analysis check that can change the code
    something_changed=`git diff-index --exit-code --ignore-submodules HEAD`
    if [ -n "$something_changed" ]
    then
        echo >&2 "Something changed in $local_ref, not pushing"
        exit 1
    fi
    

提交回复
热议问题