Fatal: pathspec 'file.txt' did not match any files, GIT

前端 未结 14 1199
难免孤独
难免孤独 2021-02-04 11:59

I have just started learing GIT. Follow their tutorial.

Now at the very beginning I got stuck with this error:

Fatal: pathspec \'file.txt\' did not match         


        
14条回答
  •  孤独总比滥情好
    2021-02-04 12:16

    In order to add a file to git it has to exist. git add does not create a file, but tells git to add it to the current branch you are on and track it.

    Currently, you have no tracked files, as you can see from your git status command. In order to track all files from the my-project directory, do a git add my-project/*. This will add all the files from that directory.

    Next, if you do not have the desired file.txt, just create a text file and run git status. It should show you that you have an untracked file.txt file, which you can afterwards add to git using git add file.txt.

提交回复
热议问题