Friday, 7 November 2014

Git prompt

A very cool and useful way to avoid issues with working on the wrong git branch is to use the git-prompt.sh script. I sometimes manage to do this mistake. I need to check something which means changing the branch, I'm distracted and when I get back to work I forget to change the branch back. This can get messy. But with git-prompt.sh current branch is always shown in the prompt! I read about this from the Git book at http://git-scm.com/book/en/v2/Git-in-Other-Environments-Git-in-Bash which also mentions git-completion.bash. I incorporated that into my .bashrc, too, but I feel that's a lot less useful than the prompt.

I changed the instructions a bit and made the prompt like this:
 export PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 " (%s)")\$ '
This will add my username and machine name in the prompt as well (I always use to have them).

No comments:

Post a comment