Quantcast
Channel: How do I get the current branch name in Git? - Stack Overflow
Viewing all articles
Browse latest Browse all 96

Answer by Siddharth Satpathy for How do I get the current branch name in Git?

$
0
0

I would try one of the following:

1.> git symbolic-ref --short HEAD

git symbolic-ref --short HEAD>>> sid-dev

2.> git branch --show-current

git branch --show-current>>> sid-dev

3.> git name-rev –name-only HEAD

git name-rev –name-only HEAD>>> HEAD sid-dev

Notes:

1.> git symbolic-ref --short HEAD displays the short symbolic reference to the current branch’s HEAD. This is the current branch name.

2.> git branch --show-current is also a simple and efficient way to print the current branch name.

3.> git name-rev –name-only HEAD gives the symbolic name for HEAD revision of the current branch

4.> In the above examples, sid-dev is the name of my branch.


Viewing all articles
Browse latest Browse all 96

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>