Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't add files to Git

Tags:

git

github

I am new to git and github and I am having trouble using Git. My path for Git looks something like this C:\Program Files\Git\code_snippets. And in the code_snippets directory I have a README.md file. Right now what I want to do is add another file like I see people in the tutorials I am watching are doing, but nothing seems to work.

I cannot create any files in the code_snippets directory only a folder, when I try using commands like git add index.html I get an error saying index.html did not match any files. the command git status says

On branch master
Your branch is up-to-date with origin
nothing to commit, working tree clean. 

Nothing I seem to do adds a file to the code_snippets directory.

like image 278
johnbumble Avatar asked Jan 25 '26 05:01

johnbumble


1 Answers

For adding files using git add , you need to have the files inside the local git repository (the local git repository will have a .git folder in it).

You cannot add some files which are outside of this folder to the repo. The files in a local repo are associated to the .git folder.

If the folder is an existing one and is not tracked by git, then do a git init inside the root folder whose content you want to track. This initialises a new git repo.

like image 143
djames Avatar answered Jan 26 '26 19:01

djames



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!