首页 > 解决方案 > How to check with Git before merge if the merge is necessary? ("Already up-to-date.")

问题描述

In a deployment pipeline I'm checking out master in a clean clone (which is the target) and then I merge the revision into it to update it.

git checkout master
git merge "${revision}"

As git has a pre-merge check it then tells in my scenario:

Already up-to-date.

when the revision was already merged.

How can I find out previous to the merge command, that this ("Already up-to-date") is the case, so that I can exit the pipeline early as there is nothing anymore to do?

标签: gitshellgit-merge

解决方案


git merge-base --is-ancestor $revision master || git merge $revision

推荐阅读