开发者

How can I get the GIT_PS1_SHOWDIRTYSTATE to not run against a bare repo?

开发者 https://www.devze.com 2023-04-11 09:24 出处:网络
So I\'ve set up bash autocompletion for my install of git, and that rocks. However, I\'开发者_Go百科ve got a bare repo that I occasionally have to directly interface with (git reset, for example), and

So I've set up bash autocompletion for my install of git, and that rocks. However, I'开发者_Go百科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.


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.


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消