Created: 2014-05-19 07:54
Updated: 2018-12-17 06:36

Initially found this script somewhere in the internet. Patched to work with different colors for clean branch, dirty branch, staged changes. For a clean branch the color is different if there are pending local or remote changes.

It looks like this:



Place the .gitrc file to your home directory. Add the following code to your .bashrc or .profile file:

# uncomment this line if your startup script doesn't set color_prompt correctly
# color_prompt=yes
if [ -f ~/.gitrc ]; then
        . ~/.gitrc

Automatically updating remote

The remote changes can be automatically updated. This can be a time consuming operation, so a reasonable update interval shoud be chosen. The feature is disabled by default and it can be set by

# Set remote update interval in seconds
git config --local prompt.updateinterval 60
# Or use a helper function
gitrc_refresh_timeout 60

To turn automatic remote update off

git config --local --unset prompt.updateinterval
# Or use a helper function
gitrc_refresh_timeout off
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more