Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 673 Bytes

choose-logic-by-commit-hash.md

File metadata and controls

28 lines (19 loc) · 673 Bytes

gitのコミットハッシュを見て、処理を続行するか判断する

結論

git rev-parseでコミットハッシュを取得できる。

たとえば、リモートで変更があるかどうかによって、処理を分岐させることができる。

git remote
# origin
# upstream

git fetch --all --prune

if [ $(git rev-parse master) = $(git rev-parse upstream/master) ]; then
    echo "Already up-to-date" >&2
    exit 0;
fi

# heavy logic
git checkout master && git merge --ff upstream/master && git push
make

参考リンク