Search code examples
gitmacoszsh

`git branch` output empty without `sudo` on macOS


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.

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.


Solution

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