How to get the current git branch


/ Published in: Bash
Save to your folder(s)

git branch will give us all the branches in the current repository and the current branch will be denoted by a * mark.


Copy this code and paste it in your HTML
  1. branch=$( git branch 2>/dev/null|grep -e ^* | tr -d \*\ )

Report this snippet


Comments


You need to login to view comments.