I have a huge git repository with a lot of branches. I need to check by shell command inside of Jenkins, if there is a branch inside of repository.
I make a clone of the single branch like this
if `sshpass -p password git clone -b "${BRANCH}" --single-branch ssh://user@server/GIT/${REPO}.git`; then
echo "success"
else
echo "ERROR: There is no branch "${BRANCH}" inside repo "${REPO}""
exit 42
fi
It workes right, but it still takes a lot of time to clone a branch. Is there a way to make it work faster (maybe without making clone of repo or with interrupting of cloning if the branch is found)?
Thanks in advance
You could parse the output of
git ls-remote http://user@server/GIT/${REPO}.git
From its documentation:
Displays references available in a remote repository along with the associated commit IDs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With