Thursday, October 24, 2024
HomeBusinessCurrent Git branch name in command prompt

Current Git branch name in command prompt

Date:

Related stories

Explore the Best Online Gambling Platforms at Macaubet

The online gambling industry has seen remarkable growth in...

Experience the Thrill: Online Pokies That Pay Real Money

Online pokies have surged in popularity, captivating millions of...

How to Access the Latest Promotions with Starzbet Yeni Giriş

In the fast-paced world of online betting, promotions play...

The Evolution of Casino Slot Machines: A Historical Perspective

Introduction to Slot Machines Slot machines, commonly known as "one-armed...

Starzbet Telegram: Instant Updates on the Best Casino Games

In the fast-paced world of online gambling, having instant...
spot_img
Since we started using Git branches as part of our dev workflow at work, it has become essential to always be sure that you’re working with the right branch. You can either always check git branch, or let the current branch name be displayed as part of the command line all the time when you’re inside a Git project. This is very convenient and helps you not to mess the things up.

There are several ways how to output the git branch name to the command line, and I’ll share the one I use and worked fine on all machines where I have tested it. I have originally found it on DeveloperZen.

If you’re working in Linux (I have tested with Ubuntu), just add the following code to .bashrc file in your home directory:

function parse_git_branch () {
  git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
 
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
 
PS1="$GREEN\u@\h$NO_COLOR:\w$YELLOW\$(parse_git_branch)$NO_COLOR\$ "

If you’re on Mac, you should put this code to .bash_profile in your home directory. For Windows you probably won’t need this because the “Git for Windows” command line interface handles this functionality by default.

The function parse_git_branch() could be replaced with predefined __git_ps1() normally available in bash, but this one didn’t work well on one of my colleagues computer (it did show the “master” branch name all the time, even if not in a git project). This snippet also adds some colors to your command prompt. How cool is that? 🙂

Latest stories

spot_img
  • https://didascaliasdelteatrocaminito.com/
  • https://glenellynrent.com/
  • https://gypsumboardequipment.com/
  • https://realseller.org/
  • https://hotelcasasanagustin.com/game/
  • https://footy.dk/dir/
  • https://idiomas.be/beer/
  • https://harrysphone.com/upin/
  • https://gyergyoalfalu.ro/tokek/
  • https://vipokno.by/gokil/
  • https://winjospg.com/
  • https://winjos801.com/
  • https://www.logansquarerent.com/
  • https://internationalfintech.com/bamsz/
  • https://pancen.id/
  • https://winjosjakrata.com//
  • https://winlotrebandung.com/
  • https://condowizard.ca/
  • https://jawatoto889.com/
  • https://hikaribet3.live/
  • https://hikaribet1.com/
  • https://heylink.me/hikaribet/
  • https://www.nomadsumc.org/
  • https://condowizard.ca/aromatoto/
  • https://euro2024gol.com/
  • https://www.imaracorp.com/
  • https://daftarsekaibos.com/
  • https://stuffyoucanuse.org/juragan/
  • https://louisvilleladder.com/totomcu/
  • https://springshomes.com/totosgp/
  • Situs Togel Resmi
  • Toto Macau
  • Aromatoto
  • Lippototo
  • Mbahtoto
  • Winjos
  • https://152.42.229.23/
  • https://bandarlotre126.com/
  • https://heylink.me/sekaipro
  • https://www.get-coachoutletsonline.com/o
  • https://wholesalejerseyslord.com/