Git status shows a weird string as an untracked file
Asked Answered
M

2

7

Git status gives me this:

$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        "\357\200\233\357\200\233OB\357\200\233q"

nothing added to commit but untracked files present (use "git add" to track)

There is no such file or directory:

$ cat $"\357\200\233\357\200\233OB\357\200\233q"
cat: '\357\200\233\357\200\233OB\357\200\233q': No such file or directory

Another weird thing is that the status command before the last commit did not show this weird path string.

Any idea what is going on? should I "git clean -f"? is it safe?

Martinez answered 20/6, 2017 at 9:13 Comment(0)
A
6

For Ubuntu/Linux :

Simply remove it command using :

sudo rm -rf "\357\200\233\357\200\233OB\357\200\233q"

This Happens when a script/command outputs as a newfile with such characters.

For Windows :

1) Go to Folder Options => Select Show Hidden & System Files

2) Browse to your Repository folder.

3) Remove the file named with "\357\200\233\357\200\233OB\357\200\233q"

Alcahest answered 20/6, 2017 at 9:24 Comment(5)
I'm on windows and don't have sudo. rm -rf "\357\200\233\357\200\233OB\357\200\233q" didn't do the job. What I did is git clean -f and it worked. I wonder what happened there. what script/command did this and why it was not detectable as a folder/file.Martinez
Answer updated, & yes its Cool, because the file must be created using system & must be hidden, using git clean -f the file is cleared & your internally called git checkout branchname -fAlcahest
Thanks for the info LuFFy.Martinez
I have the same issue, but with another string "\342\200\234/". I have tried to use sudo rm -rf "\342\200\234/", and git clean -f, but sadly none of them work. (I am on macOS Mojave)Promisee
Just a note that the filename can look differently in explorer: mine was ` \357\200\233q\357\200\233\357\200\233\357\200\233q` in git status (=raw byte string), but qq in explorer. Bottom line: Just find a weird fresh file in a repo root with half-git half-gibberish contents and delete it.Pisces
A
0

TLDR:

git config --global core.quotepath off

Git prints utf8 characters in octal format for historical reasons. You can disable it by the command above.

full explanation: https://mcmap.net/q/195454/-how-to-make-git-properly-display-utf-8-encoded-pathnames-in-the-console-window

Apsis answered 7/9 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.