在不使用 Git 的情况下在 GitHub 存储库中创建文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18773598/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:56:29  来源:igfitidea点击:

Creating folders inside a GitHub repository without using Git

gitgithubgithub-services

提问by softvar

I want to add a new folder to my newly created GitHub repository without installing the Git setup for (Mac, Linux, and Windows). Is it possible to do so?

我想向我新创建的 GitHub 存储库添加一个新文件夹,而无需安装适用于(Mac、Linux 和 Windows)的 Git 设置。有可能这样做吗?

I can't have Git all the time with me when I work on different systems/machines. I know how to add files directly in a repository on github.com/[USER]/[REPO]. Can we create a folder as well?

当我在不同的系统/机器上工作时,我不能一直带着 Git。我知道如何直接在github.com/[USER]/[REPO]. 我们也可以创建一个文件夹吗?

回答by softvar

After searching a lot I find out that it is possible to create a new folder from the web interface, but it would require you to have at least one file within the folder when creating it.

经过大量搜索后,我发现可以从 Web 界面创建一个新文件夹,但是在创建它时,您需要在该文件夹中至少有一个文件。

When using the normal way of creating new files through the web interface, you can type in the folder into the file name to create the file within that new directory.

当使用通过 Web 界面创建新文件的正常方式时,您可以在文件名中键入文件夹以在该新目录中创建文件。

For example, if I would like to create the file filename.mdin a series of sub-folders, I can do this (taken from the GitHub blog):

例如,如果我想filename.md在一系列子文件夹中创建文件,我可以这样做(取自 GitHub 博客):

Enter image description here

在此处输入图片说明

回答by Malcolm

When creating a file, use slashes to specify the directory. For example:

创建文件时,使用斜杠指定目录。例如:

Name the file:

命名文件:

repositoryname/newfoldername/filename

GitHub will automatically create a folder with the name newfoldername.

GitHub 将自动创建一个名为newfoldername的文件夹。

回答by Daniel M?ller

You can also just enter the website and:

您也可以只输入网站,然后:

  1. Choose a repository you have write access to (example URL)
  2. Click "Upload files"
  3. Drag and dropa folder with files into the "Drag files here to add them to your repository"area.
  1. 选择您具有写入权限的存储库(示例 URL
  2. 点击“上传文件”
  3. 包含文件的文件夹拖放“将文件拖放到此处以将它们添加到您的存储库”区域。

The same limitation applies here: the folder must contain at least one file inside it.

这里也有同样的限制:文件夹中必须至少包含一个文件。

回答by Eli TheHuman

Another thing you can do is just drag a folder from your computer into the GitHub repository page. This folder does have to have at least 1 item in it, though.

您可以做的另一件事是将一个文件夹从您的计算机拖到 GitHub 存储库页面中。但是,此文件夹中必须至少包含 1 个项目。