Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.