2

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.

2 Answers 2

2

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)).

2

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.

You must log in to answer this question.

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