Show git branch name in Ubuntu Linux terminal on bash prompt

Опубликовано: 14 Март 2026
на канале: Riyafa Abdul Hameed
10,992
65

This is a detailed tutorial on how to customize and show the git branch name on your bash terminal in Ubuntu, Linux or MacOS.

Watch in HD for better clarity

Get the git-prompt.sh from here: https://github.com/git/git/blob/maste...
Tutorial on customizing and colorizing bash-prompt: https://www.howtogeek.com/307701/how-...


Click on subscribe button to subscribe to the channel.


The final command generated is as follows:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;33m\]$(__git_ps1 " (%s)")\[\033[00m\]\$ '
Be sure to source the git-prompt.sh file.


But I encourage you to experiment it by yourself
The command I personally use is this:
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;34m\]\w\[\033[01;33m\]$(__git_ps1 " (%s)")\[\033[00m\]\$ '
It rids of the user and hostname which I obviously know and need not print all the time.


Please subscribe.