0

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!

3
  • 1
    Do you have non-breaking spaces between git and its parameters? Commented Nov 28, 2022 at 18:32
  • @Zak returns [~]$ echo $HOME /home/user as expected. As you might notice it actually expands fine in the error message in the post. Commented Nov 28, 2022 at 18:36
  • git --git-dir="$HOME/.git/" --work-tree="$HOME" status IMO could be simply git -C "$HOME" status Commented Nov 28, 2022 at 19:42

1 Answer 1

1

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? :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.