Home > Enterprise >  git --git-dir="$HOME/.git/" --work-tree="$HOME" status - fails with bash: No suc
git --git-dir="$HOME/.git/" --work-tree="$HOME" status - fails with bash: No suc

Time:11-29

I am having trouble with the command in title

[user ~]$ git init --bare $HOME/.git
[user ~]$ git --git-dir="$HOME/.git/" --work-tree="$HOME" status
bash: git --git-dir=/home/user/.git/ --work-tree=/home/user: No such file or directory

This happens on a particular linux machine - another one running same distro with X11 instead of Wayland executes this line just fine.

I have already tried re-installing git without success.

Any help is very appreciate at this point!

CodePudding user response:

You have non-breaking space instead of regular space between your command and its parameters:

$ od -a <<EOF
[user ~]$ git --git-dir="$HOME/.git/" --work-tree="$HOME" status
EOF
0000000   [   u   s   e   r  sp   ~   ]   $  sp   g   i   t   B  sp   -
0000020   -   g   i   t   -   d   i   r   =   "   /   h   o   m   e   /
0000040   k   n   i   t   t   l   /   .   g   i   t   /   "   B  sp   -
0000060   -   w   o   r   k   -   t   r   e   e   =   "   /   h   o   m
0000100   e   /   k   n   i   t   t   l   "  sp   s   t   a   t   u   s
0000120  nl
0000121

That B sp should be only sp.

You can also use xxd to get a hex dump:

$ xxd <<EOF
[user ~]$ git --git-dir="$HOME/.git/" --work-tree="$HOME" status
EOF
00000000: 5b75 7365 7220 7e5d 2420 6769 74c2 a02d  [user ~]$ git..-
00000010: 2d67 6974 2d64 6972 3d22 2f68 6f6d 652f  -git-dir="/home/
00000020: 6b6e 6974 746c 2f2e 6769 742f 22c2 a02d  knittl/.git/"..-
00000030: 2d77 6f72 6b2d 7472 6565 3d22 2f68 6f6d  -work-tree="/hom
00000040: 652f 6b6e 6974 746c 2220 7374 6174 7573  e/knittl" status
00000050: 0a

As you can see, there are two bytes between the command and its arguments: c2 a0 (non-breaking space), but it should be 20 (space).

Your command must be:

[user ~]$ git --git-dir="$HOME/.git/" --work-tree="$HOME" status

but you have:

[user ~]$ git --git-dir="$HOME/.git/" --work-tree="$HOME" status

Can you spot the difference? :)

  • Related