如何在GitHub存储库中创建文件夹?

问题描述:

我想在GitHub存储库中创建一个文件夹,并希望在该文件夹中添加文件.我该如何实现?

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

您不能创建一个空文件夹,然后将文件添加到该文件夹​​,但必须同时创建一个文件夹至少添加一个文件.在GitHub上,您可以这样操作:

You cannot create an empty folder and then add files to that folder, but rather creation of a folder must happen together with adding of at least a single file. On GitHub you can do it this way:

  • 转到要在其中创建另一个文件夹的文件夹
  • 点击新文件
  • 在文件名的文本字段中,首先输入要创建的文件夹名称
  • 然后键入/ .这将创建一个文件夹
  • 您可以类似地添加更多文件夹
  • 最后,给新文件起一个名字(例如,.gitkeep,它通常是 用来使Git跟踪原本为空的文件夹;但这不是Git的功能)
  • 最后,单击提交新文件.
  • Go to the folder inside which you want to create another folder
  • Click on New file
  • On the text field for the file name, first write the folder name you want to create
  • Then type /. This creates a folder
  • You can add more folders similarly
  • Finally, give the new file a name (for example, .gitkeep which is conventionally used to make Git track otherwise empty folders; it is not a Git feature though)
  • Finally, click Commit new file.