我想在GitHub存储库中创建一个文件夹,并想在该文件夹中添加文件。我该如何做到这一点?
当前回答
只需将文件夹从Windows资源管理器拖到浏览器的github上传文件显示-现在文件夹将自动添加…
其他回答
要添加新目录,您只需在本地存储库中创建一个新文件夹。创建一个新文件夹,并在其中添加一个文件。
现在转到终端,像在Git中添加普通文件一样添加它。将它们放入存储库,并检查状态以确保创建了一个目录。
简单的步骤:
步骤1:单击创建新文件
第二步:输入你想要的文件夹名称,然后按/
步骤3:输入一个示例文件名。您必须输入一些文本。
步骤4:单击Commit new file创建文件夹
步骤5:创建文件夹!
首先,您必须将存储库克隆到本地机器
git clone github_url local_directory
然后你可以在你的local_directory中创建本地文件夹和文件,并使用以下命令将它们添加到存储库:
git add file_path
你也可以添加所有的东西使用:
git add .
注意,Git不跟踪空文件夹。解决方法是在要跟踪的空文件夹中创建一个文件。我通常将该文件命名为空,但它可以是您选择的任何名称。
最后,你提交并推回GitHub:
git commit
git push
有关Git的更多信息,请参阅Pro Git书籍。
对于使用浏览器的用户,可以执行以下操作:
Once in the master repository, click on Create new file. In the name of file box at the top, enter the name of your folder Use the / key after the name of the folder. Using this forward slash creates the folder You can see a new box appear next to the folder name wherein you can type the name of your file. In the Commit new file box at the bottom of the page, you can type the description for your file. Select the radio button Commit directly to the master branch. Click on the Commit new file button You will see the new directory will be created.
Git不存储空文件夹。只要确保文件夹中有一个文件,比如doc/foo.txt,然后运行git add doc或git add doc/foo.txt,一旦你提交了,这个文件夹就会被添加到你的本地存储库中(一旦你推送它,它就会出现在GitHub上)。
推荐文章
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 在GitHub repo上显示Jenkins构建的当前状态
- 如何取消在github上的拉请求?
- HEAD和master的区别
- 在另一个目录中运行操作
- GitHub克隆与OAuth访问令牌
- 我可以在GitHub上对要点进行拉请求吗?
- Git:在推送后删除提交的文件
- 在GitHub中编辑git提交消息
- Github:导入上游分支到fork
- GitHub上的分叉和克隆有什么区别?
- 如何将现有的解决方案从Visual Studio 2013添加到GitHub
- 是否可以在GitHub上搜索特定的文件名?
- GitHub -未能连接到GitHub 443 windows/连接到GitHub失败-无错误
- 我怎么能让詹金斯CI与Git触发器推到主人?