Reputation: 7
I am trying to add a file from Visual Studio Code to Git repository. But whenever I type this code:
$ git add index.html
I get this message in my terminal:
fatal: pathspec 'index.html' did not match any files
I thought I typed the file name exactly as it was typed in my finder. Any suggestions?
Upvotes: 0
Views: 7422
Reputation: 1
git add .
(it adds all the files to the staging area)
git commit -m "message goes here"
(commit the code which is staged)
git push -u origin master
(push all the committed files to the master branch)
if you want to learn more about git, you can find complete git cheatsheet here
Upvotes: -1
Reputation: 51
Navigate to the directory where index.html is located or to the root directory of your project.
issue git add index.html
command or git stage index.html
which is equivalent git add *
for adding all files that have not been added earlier.
Then you can commit and push
git commmit -m "Some commit message here"
git push -u origin master
Upvotes: 0
Reputation: 1803
First of all let us assume your project name is myApp then at terminal you should be inside the myApp project and from there if you type git status you will get then list of newly added files or new created files from there you add file using command git add "file name along with directory path" but since you are simply adding the file without directory path so you are facing the problem.
I am providing the screenshot as how i have done
Upvotes: 0
Reputation: 110
Well, I imagine you are not in the correct folder. Just go to the folder which contains the file index.html and do these steps:
git add index.html
git commit -m "comment"
git push origin master //or whatever branch you are working in
Upvotes: 3
Reputation: 16411
Some things to try:
git status
This will show you any files that are modified or not yet in the repo (plus other status's), e.g.:
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
test/test12345.txt <<< File not yet in the repo
Here you can see there is a file to add in a sub-folder called test. So I can do:
git add test/test12345.txt
git commit -m "added new file"
If you do not see the file that you want to add, check in the .gitignore
file on the top level of your git repo. It might contain some sort of pattern to ignore the location of type or name of your file.
Upvotes: 0