#!/bin/bash
# Set the branch names
BRANCH1="master"
BRANCH2="my-feature-branch"
# Check if there are differences between the two branches
DIFFERENCES=$(git diff --name-only $BRANCH1 $BRANCH2)
# If there are differences, print a message
if [ -n "$DIFFERENCES" ]; then
echo "There are differences between the $BRANCH1 and $BRANCH2 branches."
else
echo "There are no differences between the $BRANCH1 and $BRANCH2 branches."
fi
2条答案
按热度按时间zaqlnxep1#
(edit:交换了--quiet的退出代码,这会抑制输出)
git diff --quiet
将导致命令设置退出代码,类似于正常的diff命令(如果存在差异)。k97glaaz2#
下面是一个例子:
字符串