dongzhong1891
2015-08-09 19:08 阅读 128

如何将文件夹从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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    donglue8180 donglue8180 2015-08-09 19:26

    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.

    点赞 评论 复制链接分享
  • dongzhao4036 dongzhao4036 2015-08-09 19:12

    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.

    点赞 评论 复制链接分享
  • dongqijuan3786 dongqijuan3786 2015-08-09 19:13
    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
    
    点赞 评论 复制链接分享

相关推荐