I have a Bash script which accepts a string of either a branch name (e.g., "master", or "feature/foo") or a commit hash (e.g. "1234abcd").
I have the repository checked out, so I can call Git.
What is the best way to determine whether the string is a branch name or a commit hash?
#!/bin/bashcommit_or_branch="$1"cd /path/to/my_repogit fetchif <is_branch $commit_or_branch>then echo "it's a branch"else echo "it's a commit"fi