2

So I've set up bash autocompletion for my install of git, and that rocks. However, I've got a bare repo that I occasionally have to directly interface with (git reset, for example), and any time I cd into the bare repo, the GIT_PS1_SHOWDIRTYSTATE setting I have to show me the status of my normal working trees runs, and I see this message:

fatal: This operation must be run in a work tree

It is, I think, trying to run a git status against that repo, but being bare, it reports an error.

I'd love to not see that error every time I do anything in my bare repo; it's thrown me off a few times already.

jeffbyrnes
  • 2,182
  • 2
  • 22
  • 33
  • Are you using an old version of the git completion? I don't have this problem. – Cascabel Oct 06 '11 at 15:07
  • Grabbed this gist to set things up: https://gist.github.com/58383. I'm gonna go out on a limb & guess it's not the most recent one… – jeffbyrnes Oct 06 '11 at 18:02
  • Depending on your distro, git completion will be installed as part of one of the git packages. That should be your first choice. After that, you should either take the version from a stable release (download from http://git-scm.com) or the current master branch of git.git: https://github.com/gitster/git – Cascabel Oct 06 '11 at 19:31

2 Answers2

1

You can do a git config core.bare on your repo to check whether it is bare or not. This is reliable if the repository was created using git init --bare. It will return true for bare repositories and false for others. You can use this to filter adjust your completion script as appropriate.

Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169
1

So, as it turned out, using that gist was exactly the reason for this not working correctly. I set my .bash_profile to load the bash completion that came with my install of Git, and all is well. Thanks!

jeffbyrnes
  • 2,182
  • 2
  • 22
  • 33