1

I am using git on ubuntu.

git branch does not show the branches' names. I tried cloning different repositories, but again git branch does not show the branches' names. I have also created a new repository and it is the same.

Example:

>git clone https://github.com/uber/pyro.git
Cloning into 'pyro'...
remote: Counting objects: 13342, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 13342 (delta 8), reused 0 (delta 0), pack-reused 13319
Receiving objects: 100% (13342/13342), 55.85 MiB | 5.34 MiB/s, done.
Resolving deltas: 100% (9814/9814), done.
>ls
pyro
>cd pyro
>git branch -a
>git branch -r
>git branch
>git status
On branch dev
Your branch is up to date with 'origin/dev'.

Adding another branch:

>git checkout -b branch1
Switched to a new branch 'branch1'
>git branch
>

I have also committed one time. and it is the same.

>GIT_TRACE=1 git branch
15:39:13.295464 git.c:344               trace: built-in: git branch
15:39:13.296121 run-command.c:640       trace: run_command: unset 
GIT_PAGER_IN_USE; LESS=FRX LV=-c pager
>git --version
git version 2.17.1
>
>env -i git branch
WARNING: terminal is not fully functional
* devress RETURN)
>

I have tested the same commands on another laptop and it works. (I have also uninstalled git and reinstalled it. It doesn't help)

Any idea how to fix it?

A_sh
  • 21
  • 8
  • Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackoverflow.com/rooms/173128/discussion-on-question-by-a-sh-git-branch-does-not-show-the-branches-names). –  Jun 14 '18 at 09:16
  • Update: I disabled the git pager for the `git branch` by using `git config --global pager.branch false`. Now I can get the results. But as @Keith said, we still don't know why pager cause this problem. – A_sh Jun 18 '18 at 21:01

3 Answers3

1

This is not a complete answer, but based on a lengthy chat discussion, it looks like some kind of interaction with the pager.

The user's environment includes these variables (among others):

LESSOPEN='| /usr/bin/lesspipe %s'
LESSCLOSE='/usr/bin/lesspipe %s %s'

Those are the default settings on Ubuntu, so that shouldn't be causing a problem.

git branch produces no output.

GIT_PAGER=/bin/cat git branch produces the correct output.

I haven't yet figured out why the pager should be causing this problem, but since changing GIT_PAGER to /bin/cat is a workaround, that must be what the issue is.

Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
0

Show local branches:

git branch

Since you are cloning from remote/origin branches, it will not displaying using git branch. you need to at least visit that branch by using git checkout. Review below git commands. I have created new branch hotfix-test and then used git branch

~/pyro (dev)

    $ git checkout -b hotfix-test
    Switched to a new branch 'hotfix-test'

~/pyro (hotfix-test)

    $ git branch
      dev
    * hotfix-test

Checkout the current branch to existing other branch.

$ git checkout lax
Switched to a new branch 'lax'
Branch lax set up to track remote branch lax from origin.

~/pyro (lax)
 $ git branch
          dev
          hotfix-test
        * lax

Cloning steps and origin branches

 ~/desktop (master)
$ git clone https://github.com/uber/pyro.git
Cloning into 'pyro'...
remote: Counting objects: 13342, done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 13342 (delta 8), reused 0 (delta 0), pack-reused 13319
Receiving objects: 100% (13342/13342), 55.85 MiB | 2.69 MiB/s, done.
Resolving deltas: 100% (9814/9814), done.

~/desktop (master)
$ cd pyro

desktop/pyro (dev)
$ git branch -a
* dev
  remotes/origin/0.1.2-release
  remotes/origin/0.2.0-release
  remotes/origin/0.2.1-release
  remotes/origin/HEAD -> origin/dev
  remotes/origin/ast-char-rnn
  remotes/origin/bnn-mnist
  remotes/origin/causal-tutorial
  remotes/origin/continuation-poutine
  remotes/origin/continuation-with-indep
  remotes/origin/cubo
  remotes/origin/dev
  remotes/origin/dice-elbo
  remotes/origin/gh-pages
  remotes/origin/glom-autoname
  remotes/origin/hmc
  remotes/origin/jit-integration-tests
  remotes/origin/lax
  remotes/origin/lax2
  remotes/origin/maps-iei
  remotes/origin/master
  remotes/origin/mvn-sym
  remotes/origin/mvncv
  remotes/origin/nightmare-poutine
  remotes/origin/nips-2017
  remotes/origin/only-continuation-poutine
  remotes/origin/only-parallel-enumeration
  remotes/origin/paul-mh-12-1
  remotes/origin/pcg
  remotes/origin/pragmatics-example
  remotes/origin/ps-semaphore
  remotes/origin/pyro_GP
  remotes/origin/recursion-scope
  remotes/origin/regtest-1
  remotes/origin/rejector-research
  remotes/origin/revert-611-verlet-pr
  remotes/origin/rsa-ccg-example
  remotes/origin/sampling-hash
  remotes/origin/snorkel-example
  remotes/origin/trace-posterior-sample-fix
  remotes/origin/tst
  remotes/origin/vec-rand-module

 ~/desktop/pyro (dev)
$ git branch -r
  origin/0.1.2-release
  origin/0.2.0-release
  origin/0.2.1-release
  origin/HEAD -> origin/dev
  origin/ast-char-rnn
  origin/bnn-mnist
  origin/causal-tutorial
  origin/continuation-poutine
  origin/continuation-with-indep
  origin/cubo
  origin/dev
  origin/dice-elbo
  origin/gh-pages
  origin/glom-autoname
  origin/hmc
  origin/jit-integration-tests
  origin/lax
  origin/lax2
  origin/maps-iei
  origin/master
  origin/mvn-sym
  origin/mvncv
  origin/nightmare-poutine
  origin/nips-2017
  origin/only-continuation-poutine
  origin/only-parallel-enumeration
  origin/paul-mh-12-1
  origin/pcg
  origin/pragmatics-example
  origin/ps-semaphore
  origin/pyro_GP
  origin/recursion-scope
  origin/regtest-1
  origin/rejector-research
  origin/revert-611-verlet-pr
  origin/rsa-ccg-example
  origin/sampling-hash
  origin/snorkel-example
  origin/trace-posterior-sample-fix
  origin/tst
  origin/vec-rand-module

See Also Why is "git branch" silent in new repositories?

Nisarg
  • 1,631
  • 6
  • 19
  • 31
0

I have disabled the git pager for the git branch by using git config --global pager.branch false. Now I can get the git branch output. But we didn't figure out what is the pager problem. For the other commands like git diff, the same problem exists.

A_sh
  • 21
  • 8