johnbumble
johnbumble

Reputation: 700

Can't add files to Git

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.

Upvotes: 3

Views: 8700

Answers (2)

djames
djames

Reputation: 366

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.

Upvotes: 3

Tse Kit Yam
Tse Kit Yam

Reputation: 303

git add index.html won't add a file to file system, it adds file to git only.

Use any editor to create index.html file in your code_snippets folder first, then use git add index.html to tell git to track this file

Upvotes: 2

Related Questions