PracticalWeb Ltd

Websites that work for you.

Mini Scripts to Obtain Git Id/branch/tag

1
2
3
4
5
6
7
8
9
10
$new_branch=$1 # passed as param

current_branch="$(git symbolic-ref HEAD 2>/dev/null)"
current_branch=${current_branch##refs/heads/}

current_id=$(git rev-parse --short origin/$current_branch)

new_id=$(git rev-parse --short origin/$new_branch)

last_tag=$(git describe --abbrev=0 --tags)

Comments