The git repository is under my username nikhil
and group nikhil
as follows:
$ ls -l
drwxr-xr-x 10 nikhil nikhil 4096 Sep 1 12:33 CS/
I can get git status as git status
without root privilege.
But when I try to list branches:
$ git branch -a
nothing happens.
Also, with root priviledge:
$ sudo git branch -a
[sudo] password for nikhil:
* master
remotes/origin/feature
remotes/origin/master
it does lists all my repository.
Why is it so?
Edit: output of ls -lh .git
$ ls -lh .git
total 332K
drwxr-xr-x 2 nikhil nikhil 4.0K May 25 16:32 branches
-rw-r--r-- 1 nikhil nikhil 2 Sep 1 12:25 COMMIT_EDITMSG
-rw-r--r-- 1 nikhil nikhil 5.6K Sep 1 12:33 config
-rw-r--r-- 1 nikhil nikhil 73 May 25 16:32 description
-rw-r--r-- 1 nikhil nikhil 90 Sep 1 12:33 FETCH_HEAD
-rw-rw-r-- 1 nikhil nikhil 23 Sep 1 12:33 HEAD
drwxr-xr-x 2 nikhil nikhil 4.0K Jun 11 15:25 hooks
-rw-r--r-- 1 nikhil nikhil 229K Sep 1 12:34 index
-rw-r--r-- 1 nikhil nikhil 44K Jun 11 08:56 INDEX
drwxr-xr-x 2 nikhil nikhil 4.0K Jun 11 15:25 info
drwxr-xr-x 3 nikhil nikhil 4.0K Jun 11 15:28 logs
drwxr-xr-x 8 nikhil nikhil 4.0K Aug 11 18:01 modules
drwxr-xr-x 260 nikhil nikhil 4.0K Jun 27 15:29 objects
-rw-rw-r-- 1 nikhil nikhil 41 Sep 1 12:33 ORIG_HEAD
drwxr-xr-x 5 nikhil nikhil 4.0K Jun 11 15:25 refs
I identified the problem it was due to Anaconda in my .bashrc
:
export PATH="$HOME/anaconda3/bin:$PATH"
if [ -f $HOME/anaconda3/etc/profile.d/conda.sh ]; then
source $HOME/anaconda3/etc/profile.d/conda.sh
fi
conda activate
What should I do? When I comment this out git branch -a
works.
conda
provides its ownpager
binary (notmore
orless
, butpager
). Usingsudo
clears your PATH -- so it fixes the problem not by virtue of changing permissions, but by virtue of preventing this faulty binary from being used at all.To prevent this from having any undesired behaviors, move it out of the way: