git retrieve branch name code example Example 1: get current branch name git git rev-parse --abbrev-ref HEAD Example 2: git liste branches $ git branch