如何将文件夹从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.
我为我的PHP项目创建了一个GitHub存储库。 所有文件都位于 这一次, 它只是不起作用。 当我尝试这样做: / home / nikola / public_html / todo / code>中。 但是,我不知道如何添加它。 我是第一次输入它: p>
git add~ / public_html / todo
code> pre>
git add~ / public_html / todo code>并输入git status它表示还没有提交一个文件(todo),但是那个文件和目录中的目录! 我找不到解决方案。 我已经在
/ home / nikola / todo code>中克隆了存储库normal并试图这样做。 p>
div>
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