如何在 GitHub 存储库中创建文件夹? [英] How do I create a folder in a GitHub repository?

查看:47
本文介绍了如何在 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?

推荐答案

TL;DR 在文件名字段中使用 / 来创建文件夹,例如在文件名字段中输入 folder1/file1 将创建一个文件夹 folder1 和一个文件 file1.

TL;DR Use / in the file name field to create folder(s), e.g. typing folder1/file1 in the file name field will create a folder folder1 and a file file1.

原答案
您不能创建一个空文件夹然后将文件添加到该文件夹​​中,而是创建文件夹必须同时添加至少一个文件.这是因为 git 不跟踪空文件夹.

Original answer
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. This is because git doesn't track empty folders.

在 GitHub 上你可以这样做:

On GitHub you can do it this way:

  • 转到要在其中创建另一个文件夹的文件夹
  • 点击新建文件
  • 在文件名的文本字段中,首先写下您要创建的文件夹名称
  • 然后输入 /.这将创建一个文件夹
  • 您可以类似地添加更多文件夹
  • 最后,为新文件命名(例如,.gitkeep,这是传统em> 用于让 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.

这篇关于如何在 GitHub 存储库中创建文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆