vendredi 17 avril 2015

How to tell git branch name from commit hash?


Vote count:

0




I have a bash script which accepts a string of either a branch name or a commit hash.


What is the best way to determine whether the string is a branch name or a commit hash?



#!/bin/bash
commit_or_branch="$1"
if <is_branch $commit_or_branch>
then
echo "it's a branch"
else
echo "it's a commit"
fi


asked 22 secs ago

kristi

3,902






How to tell git branch name from commit hash?

Aucun commentaire:

Enregistrer un commentaire