1

When I run git branch -a in a folder with a .git directory, NOTHING is returned. I have been working in this directory for a few months and git branch used to return all local and remote branches.

My PyCharm IDE can still see all of the branches just fine.

I have searched for answers throughout SO and other sites to no avail.

krkaufma
  • 39
  • 7
  • 1
    Do you perhaps not have any local branches? What does `git branch -a` show? – Brian61354270 Sep 07 '21 at 23:04
  • What does `ls .git/refs/heads` show? – William Pursell Sep 07 '21 at 23:04
  • 2
    What is your pager set to? (Run `git var pager`.) Does `git --no-pager branch` work? – torek Sep 07 '21 at 23:18
  • You said ".git file". Did you mean ".git directory"? (I assume yes if it's the "same" directory you've been using, and if you can see the branches from another Git client looking at the same place.) – TTT Sep 07 '21 at 23:52
  • `git branch -a` returns NOTHING. I did mean git directory. – krkaufma Sep 09 '21 at 01:56
  • `git var pager`: usage: git var (-l | ) – krkaufma Sep 09 '21 at 17:52
  • `ls .git/refs/heads`: 09/07/2021 03:50 PM . 09/07/2021 03:50 PM .. 08/24/2021 03:23 PM 41 cleanup 09/07/2021 03:50 PM 41 develop 08/12/2021 11:37 AM 41 main 09/02/2021 04:24 PM 41 release 4 File(s) 164 bytes 2 Dir(s) 372,438,401,024 bytes free – krkaufma Sep 09 '21 at 17:53

1 Answers1

2

git branch used to return all local and remote repositories.

Only git branch -a would return all local and remote tracking branches (branches, not "repositories").

Check first if, as commented, this is a pager issue. Change shell (if you are on Windows, switch between CMD, Powershell or bash, to see if the issue persists)

git --no-pager branch does work!
How do I fix git branch based on this info?

As noted in git config:

To disable pagination for all commands, set core.pager or GIT_PAGER to cat.

git config core.pager cat

But for disabling it only for git branch, you have various options as described in the similar question "How do I prevent 'git diff' from using a pager?"

An alias for git -P branch would be one of them. (-P is --no-pager)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `git --no-pager branch` does work! How do I fix git branch based on this info? The linked pager issue SO does not sufficiently describe how to fix the problem. – krkaufma Sep 09 '21 at 17:55
  • 1
    @krkaufma I have edited the answer to address your comment. – VonC Sep 09 '21 at 18:43
  • `git config core.pager cat` in the command line fixed the issue – krkaufma Sep 09 '21 at 19:16