Closed toukoubun closed 3 years ago
For git to work, the work directory needs to be inside the git repository. When your .bashrc
is executed, the work directory will be changed, and the git repository is not found.
One way to fix this is to change the work directory only when bash is not invoked with the -c
flag (to execute a command), i.e. replace your cd ~
with something like this (untested):
[[ $- != *c* ]] && cd ~
Please report back if this fixes the problem for you.
Thank you! After changing cd ~
to [[ $- != *c* ]] && cd ~
, this problem is fixed!
The default work directory when I start wsl2 is
/mnt/c/Users/user_name
To make the default work directory becomes my home, I added the commandcd ~
to~/.bashrc
After doing this, when I try to fetch/push in fork, the error happened