Pages

Thursday, 6 September 2018

Quickie: Checking a remote branch exists in Bash

This bash script will check that a branch exists on the first remote returned. 


if git branch -r --contains $(git remote | head -1)/branch-to-check &> /dev/null ; then
    echo "Branch Exists"
else
   echo "Branch does not exist"
fi

No comments:

Post a Comment