简体   繁体   中英

Git Add command gets fatal: pathspec on existing file

I have installed Git on Windows 10, created a new folder and executed a git init successfully and created a file named "test1.html" in the same folder. The "git add test1.html" command from the git bash console returns the following error message:

fatal: pathspec 'test1.html' did not match any files

executing an "ls -la" command returns proof the hidden.git subfolder is there along with the file I'm trying to add. Screenshot included shows such.

Any ideas what's wrong?

在此处输入图像描述

Confirm first that ls 'test1.html' does work, in case the filename ends with (invisible) spaces.

Then try the same git add in a CMD (without git bash) to see if the issue persists.

As phd adds in the comments , using cat -ETv , with -v for " --show-nonprinting ", you can see if there are any extra space by looking at the trailing ' $ ' in:

vonc@vclp MINGW64 ~/git/gitw (bubbletea)
$ ls -la | cat -ETv
total 13785$
drwxr-xr-x 1 vonc 197121       0 Jun 12 21:18 .$
drwxr-xr-x 1 vonc 197121       0 Jun  9 00:12 ..$
drwxr-xr-x 1 vonc 197121       0 Jun 13 11:49 .git$
-rw-r--r-- 1 vonc 197121      21 May 29 22:59 .gitattributes$
-rw-r--r-- 1 vonc 197121      88 Jun 10 20:44 .gitignore$
-rw-r--r-- 1 vonc 197121     511 Jun 11 18:41 go.mod$
-rw-r--r-- 1 vonc 197121    7418 Jun 11 18:41 go.sum$
drwxr-xr-x 1 vonc 197121       0 May 30 00:03 internal$
-rw-r--r-- 1 vonc 197121   12428 Jun 10 20:44 main.go$

try to run this commmand.
git config core.longpaths true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM