Pages

Thursday, August 30, 2012

Add Git Branch to Bash prompt and a git goodie - SourceTree

Adding git branch to your bash prompt has become easier than before.

Edit your ~/.bash_profile to add following code

# Set git autocompletion 
if [ -f /usr/local/git/contrib/completion/git-completion.bash ]; then
  . /usr/local/git/contrib/completion/git-completion.bash
fi

GIT_PS1_SHOWDIRTYSTATE=true

if [ -f /opt/local/etc/bash_completion ]; then
    . /opt/local/etc/bash_completion
fi

PS1='\[\033[34m\]\w\[\033[31m\]$(__git_ps1)\[\033[00m\]\$ '

It not only adds branch name but also indicates the current status of your project. For example, when you add files to staging area, + is added after branch name. 
If you make further changes to staged files, it adds * after branch name to indicate there are unstaged files.

The above script also enables Git autocompletion which will help saving some keystrokes.

If you prefer GUI tool and even if you prefer command line, SourceTree is a must have tool for Mac users. It shows you all branches, their commits, the changes. You can do everything using it.


For newbies, it will make using git a lot more fun!

5 comments:

  1. Thanks for the tip. Definitely useful for power Git users.

    ReplyDelete
    Replies
    1. Thanks for reading :) I never expected Google geek would read my blog :)

      Delete
  2. In : Tombol All in digunakan apabila anda ingin mempertaruhkan semua chip yang anda punya. Gunakan tombol ini jika memang anda yakin kartu anda yang terbaik
    asikqq
    http://dewaqqq.club/
    http://sumoqq.today/
    interqq
    pionpoker
    bandar ceme terbaik
    betgratis
    paito warna terlengkap
    forum prediksi

    ReplyDelete

  3. it's far very clean that I ought to try to conceal from that when they can. Male Enhancement is the fine ever. i will keep precise chaps from being burned by means of Male Enhancement scams. i have a large stake in that.
    https://www.nutrahealthpro.com/pure-vigor-x/

    https://www.facebook.com/nutrahealthpro/posts/211865677319900

    https://twitter.com/nutrahealthpro/status/1354741854311378946

    https://in.pinterest.com/pin/596867756863817361

    https://www.instagram.com/p/CKlgxLdlJaB/

    https://sites.google.com/view/pure-vigor-x-review/home

    https://nutrahealthpro1.blogspot.com/2021/01/purevigorx.html

    ReplyDelete
  4. Casino, Hotel and RV Park in St. Louis - Mapyro
    The St. Louis area casinos are located 안동 출장샵 in St. Louis. 수원 출장마사지 Casinos & Nightlife 통영 출장안마 is just 나주 출장마사지 35 minutes away from St. Louis 용인 출장안마 Casino.

    ReplyDelete