如何将文件夹从public_html添加到GitHub存储库?

I made a GitHub repository for my PHP project. All files are located in /home/nikola/public_html/todo/. However, I don't know how to add it. First time I made it by typing this:

git add ~/public_html/todo

This time, it just doesn't work. When I try to do: git add ~/public_html/todo and type git status it says that one file is not yet commited (todo) but that's directory with files and directories in it! I can't find solution. I have cloned repository normal in /home/nikola/todo and tried to do this.

You seem to have something wrong with your github repository layout. The files that you want to add to your repository must be within the repository source tree.

The way I understand it, your git repo is in ~/todo and you want to add files from ~/public_html/todo, but this is not how git works. Copy your files into ~/todo (cp -r ~/public_html/todo/* ~/todo/) and try again.

git add and git commit are two different commands. Simply typing git add filename.ext only tracks the files and makes them ready to be committed.

If you are looking for the files to be shown in your remote repository, you need to git commit the tracked files, and then git push them to the remote repo.

Git has an interactive learning tool that can help you learn and understand Git. I recommend checking it out until you are comfortable using the version control software.

cd /home/nikola/public_html/todo/

If you have not already initialised a repo start with

git init

To add all files in this and any subfolders

git add .
git commit