1

I have installed git version 2.1.0 on ubuntu 14.10.

I have a created a local git repository and now I would like to have my branches highlighted with colors in the ubuntu default terminal.

I have done :

git config --global color.ui true

But it has no effect on the terminal (I have tried to restart it).

This is the content of my ~/.gitconfig file:

$ cat ~/.gitconfig 
[alias]
    st = status
        co = checkout
[color]
    ui = true
    branch = auto
    diff = auto
    interactive = auto
    status = auto

Any ideas why branches are not coloured/highlighted in the ubuntu terminal when I am inside my repository?

I have read this:

How to color the Git console in Ubuntu?

But that does provide any help

enter image description here

I was expecting something like this: enter image description here

Community
  • 1
  • 1
u123
  • 15,603
  • 58
  • 186
  • 303

2 Answers2

0

If you're expecting the branch name to be colored by git status it appears you have to turn this explicitly on. My guess is it's missing a default color for color.ui = auto to apply.

[color "status"]
    branch = green
Schwern
  • 153,029
  • 25
  • 195
  • 336
0

If you want to have the branch name in prompt, add to .bashrc:

gitbranch() {
    [ -d .git ] && git name-rev --name-only @ | sed -e "s/\\(.*\\)/[\\1]/"
}

PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[\033[00;32m\]$(gitbranch)\[\033[00m\] $ '

The branch will be colored green due to \[\033[00;32m\]$(gitbranch)\[\033[00m\].

enter image description here

svlasov
  • 9,923
  • 2
  • 38
  • 39