在 macOS 上没有 `sudo` 的 `git branch` 输出为空 [英] `git branch` output empty without `sudo` on macOS
问题描述
我遇到了一个问题,即 git branch
的输出是空的,没有 sudo
.这适用于任何 git repo(至少我测试过的所有),包括新的.我已经在 zsh
、bash3
和 bash5
中测试了这个,两者都有 git
的捆绑版本和 Homebrew 版本.有趣的是,git checkout
自动完成(使用 oh-my-zsh 的 git 插件)仍然按预期工作,以及 git branch --show-current
.
I am having an issue where the output of git branch
is empty without sudo
. This applies to any git repo (at least all that I have tested), including new ones. I have tested this in zsh
, bash3
and bash5
, both with the bundled version of git
and the Homebrew version. Interestingly, git checkout
autocomplete (using git plugin of oh-my-zsh) still works as expected, as well as git branch --show-current
.
我怀疑存在 UNIX 权限问题,但我在 .git/
中找不到任何没有 -r--r--r--
的文件或目录权限或更高,或者不属于当前用户.
I suspect a UNIX permission problem, but I cannot find any file or directory in .git/
that does not have -r--r--r--
permissions or higher, or that are not owned by current user.
推荐答案
问题是一个错误的 .gitconfig
.我将寻呼机设置为 LESSCHARSET="UFT-8 less -RF
.-F
导致寻呼机在遇到 EOF
时终止,less
在终止后不保留输出,导致明显的空输出.
The problem was a bad .gitconfig
. I had the pager set to LESSCHARSET="UFT-8 less -RF
. -F
causes the pager to terminate when it hits EOF
and less
does not keep output after termination, causing the apparent empty output.
这篇关于在 macOS 上没有 `sudo` 的 `git branch` 输出为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!