How do I create a folder in a GitHub repository?

后端 未结 12 1167
庸人自扰
庸人自扰 2020-12-02 03:40

I want to create a folder in a GitHub repository and want to add files in that folder. How do I achieve this?

12条回答
  •  再見小時候
    2020-12-02 04:12

    First you have to clone the repository to you local machine

    git clone github_url local_directory
    

    Then you can create local folders and files inside your local_directory, and add them to the repository using:

    git add file_path
    

    You can also add everything using:

    git add .
    

    Note that Git does not track empty folders. A workaround is to create a file inside the empty folder you want to track. I usually name that file empty, but it can be whatever name you choose.

    Finally, you commit and push back to GitHub:

    git commit
    git push
    

    For more information on Git, check out the Pro Git book.

提交回复
热议问题