git - 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?
解决方案
git merge-base --is-ancestor $revision master || git merge $revision
推荐阅读
- c# - 不应加载引用程序集以供执行。它们只能在 Reflection-only loader 上下文中加载
- pandas - 如何根据与事件相关的值索引 [pandas] 用值填充事件
- google-assistant-sdk - Google Home 录音
- angular - Google Firebase Angular Firestore switchMap - Firebase 错误 DocumentReference.set()
- javascript - 解析字符串中奇怪字符的问题
- ocaml - 如何修复 Ocaml Unbound 构造函数错误
- ios - 如何加载文本文件的内容并将其显示在 SwiftUI 文本视图中?
- r - 如何使用 tsibble 对象生成时间序列图?
- java - 为 Java 中的自定义异常抛出定义的消息
- c - 为什么使用信号处理程序在此代码中出现分段错误?