Tag Archives: Git

Add GIT branch information to Bash prompt

I’ve seen such as fancy Bash prompts on various tutorials and Linux examples over the Internet and I’ve always wondered how is achieved. I never really had a enough free time to learn more about it and explore the options. But being jobless for a month gave me opportunity to play with the thinks I like 🙂

My solution is pretty simple: when you navigate to git controlled folder, the bash prompt will show “@ branch” after the directory name. Nothing fancy.

Just open your ~/.bashrc configuration file with your favorite editor and add the following:

get_git_branch () {
git name-rev HEAD 2> /dev/null | sed "s/[a-zA-Z0-9]\+\ \(.*\)/ @ \1/"

than put this into your PS1 string:


so it become something like that

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w$(parse_git_branch) \n\$\[\033[00m\] '

Restart your terminal or type bash to start new bash session. Navigate to git controlled folder to test. It should look like this:


How to set up a Msysgit Server with WinSSHD on Windows

Setting up Git can be tricky on Windows and this tutorial will save you few hours head bangs. This guide will take you through the steps to install and configure Git on Windows and use it as remote repo.

1) Install Git for Windows http://msysgit.github.com/

2) Right click on “My Computer” icon and select “Properties”. Than choose “Advanced system settings” from the menu on left. On the newly opened window select “Advanced” tab and click “Environment Variables”.  On “User variables for <username>” section click on “Path” and than click the “Edit” button. Add the following to the path variable, using ; as delimeter:

on x86 Windows;

C:\Program Files\Git\bin;C:\Program Files\Git\libexec\git-core;C:\Program Files\Git\cmd

or on x64 Windows:

C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\libexec\git-core;C:\Program Files (x86)\Git\cmd

3) Install WinSSHD (http://www.bitvise.com/winsshd)

4) Right click tray icon -> Settings -> Edit -> Access Control -> Windows Groups -> Everyone -> Edit
5) Change “terminal shell” to
"C:\Program Files (x86)\Git\bin\sh.exe" -il

6. Change “exec request prefix” to

"C:\Program Files (x86)\Git\bin\sh.exe" -c "