1

I'm on a Mac, I've installed git via brew and sourced the git-completion.bash script file.

I've exported the GIT_PS1_SHOWDIRTYSTATE=1 variable to also show the status of the current branch.

Finally I've included the $(__git_ps1 '(%s)') in my PS1 definition.

As I read around

# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty
# value, unstaged (*) and staged (+) changes will be shown next
# to the branch name. You can configure this per-repository
# with the bash.showDirtyState variable, which defaults to true
# once GIT_PS1_SHOWDIRTYSTATE is enabled.

But no matter what my prompt shows me (name_branch #). I've no idea what the # symbol is supposed to mean. Also I couldn't find the official repo or documentation for this file.
Any hint?

Thanks

EDIT: This is my PS1:

PS1="${Yellow}\$(__git_ps1 '(%s)')${Green}\u@${Green}\h${Color_Off}:${Blue}\w\$${Color_Off} "

Also I want to add that __git_ps1 is correctly activated only on git directories but it shows that # symbol anyway.

Leonardo
  • 4,046
  • 5
  • 44
  • 85
  • 1
    `#` pops up if an internal call to `git rev-parse --verify HEAD` fails. I'm not entirely sure what conditions cause that to happen, but that's the immediate source of `#`. – chepner Oct 28 '13 at 21:24
  • How did you set the value of `PS1`? It's possible that `__git_ps1` was *called* when you set `PS1`, instead of having it run each time `PS1` is evaluated to display the prompt. In that case, it would have been called in a non-git directory, causing the call to `git rev-parase` to fail. – chepner Oct 28 '13 at 21:49
  • Ok, this happens only on fresh git repositories. Once I've created at least one commit the PS1 correctly shows the `+` or `*` symbols instead. I found this: http://stackoverflow.com/a/12887486/1191416 I'm not sure if this is a `__git_ps1` bug or not. But more important: where can I find the original repo. or documentation for this file? Any help is appreciated. – Leonardo Oct 28 '13 at 22:12
  • I think it is included in the git distribution now (my RPM has it as `/etc/bash_completion.d/git`. I don't think it's a bug; I think it's just an indication that the repository is empty ("hey, you! commit something!"). Unfortunately, the code itself is pretty much the only documentation that I am aware of. – chepner Oct 29 '13 at 12:12
  • It's worth to mention that the completion and the prompt functionalities were [split](https://github.com/git/git/commit/af31a456b4cd38f2630ed8e556e23954f806a3cc). Here's the separated [git-prompt.sh](https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh) script. Although I couldn't find the exact explanation for the `#` symbol.. – Leonardo Oct 29 '13 at 14:14
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/40198/discussion-between-chepner-and-leonardo) – chepner Oct 29 '13 at 14:47

0 Answers0