- git branch --sort=refname: sort Branches Alphabetically.
- grep -E "^*|^": Filters the list, ensuring the current branch (marked with *) is shown first
3.sort -k1,1r: Sorts branches, ensuring the current branch is displayed at the top.
You can run directly the below command to sort current branch in first
git branch --sort=refname | grep -E "^*|^" | sort -k1,1r