Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on a Mac (10.6.5). Here's an example of what's going wrong:

[m@m ~ (master)]$ cd ~/Documents
[m@m ~/Documents (master)]$ cd ~/Applications
[m@m ~/Applications (master)]$ cd ~/Library
[m@m ~/Library (master)]$ cd ~/Sites/somesite
[m@m ~/Sites/somerepo (FEATURE_SOMEFEATURE)]$

Here's the relevant contents of my .bash_profile:

source ~/.git-completion.bash
PS1='[\u@\h \w$(__git_ps1 " (%s)")]\$ '

I'm using the standard git-completion script - I just copied it to my home directory.

share|improve this question
up vote 1 down vote accepted

I suspect that you have initialized your home directory as a Git repository.

You should be able to verify this by checking the output of git rev-parse --git-dir in ~/Documents and ~/Applications (i.e. anywhere you are unexpectedly seeing master in your prompt). The results will likely tell you that Git is using /Users/yourname/.git as the GIT_DIR for those other directories. This will be the case for any (transitive) subdirectory of your home directory that is not itself another repository (or under one that is closer than your home directory).

The same goes for having the root directory or /Users initialized as a Git repository (the prompt would pickup its status for anything under them that is not its own Git repository (or under such another Git repository)).

share|improve this answer

This is a defect in __git_ps1. The issue is that the branch name is not updated after you changed the directory. Even after checking out another branch the PS1 still shows the branch you checked out before. Appears on OS X only, on Linux it works fine.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .