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

Answer by Abdennour TOUMI for How do I get the current branch name in Git?

$
0
0

Add it to PS1 using Mac :

PS1='\W@\u >`[ -d .git ] && git branch | grep  ^*|cut -d"" -f2`> $ '

Before running the command above :

enter image description here

After running that command :

enter image description here

Dont worry, if it is not GIT repository , it will not display error because of [-d .git] which checks if .git folder exists or not.


Viewing all articles
Browse latest Browse all 96

Trending Articles



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