我想在GitHub存储库中创建一个文件夹,并想在该文件夹中添加文件。我该如何做到这一点?
当前回答
实际上GitHub并不创建空文件夹。
例如,在C:\Users\Username\Documents\GitHub\Repository目录下创建一个文件夹:
创建一个名为docs的文件夹 在docs下创建一个名为index.html的文件 打开桌面应用程序GitHub 它会自动同步,它会在那里。
其他回答
您只需在本地存储库中创建所需的文件夹。例如,您创建了app和config目录。
您可以在这些文件夹下创建新文件。
Git规则:
首先,我们需要向目录中添加文件。 然后提交这些添加的文件。
Git命令执行提交:
Git添加app/ config/ git提交
然后给出提交消息并保存提交。
然后推送到远程存储库,
git push origin remote
首先,您必须将存储库克隆到本地机器
git clone github_url local_directory
然后你可以在你的local_directory中创建本地文件夹和文件,并使用以下命令将它们添加到存储库:
git add file_path
你也可以添加所有的东西使用:
git add .
注意,Git不跟踪空文件夹。解决方法是在要跟踪的空文件夹中创建一个文件。我通常将该文件命名为空,但它可以是您选择的任何名称。
最后,你提交并推回GitHub:
git commit
git push
有关Git的更多信息,请参阅Pro Git书籍。
实际上GitHub并不创建空文件夹。
例如,在C:\Users\Username\Documents\GitHub\Repository目录下创建一个文件夹:
创建一个名为docs的文件夹 在docs下创建一个名为index.html的文件 打开桌面应用程序GitHub 它会自动同步,它会在那里。
要添加新目录,您只需在本地存储库中创建一个新文件夹。创建一个新文件夹,并在其中添加一个文件。
现在转到终端,像在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.
推荐文章
- 在Markdown Jekyll中使用图像说明
- 如何修改GitHub拉请求?
- 如何在Github和本地删除最后n次提交?
- 如何将文件附加到GitHub问题?
- 如何添加谷歌分析跟踪ID到GitHub页面
- 差异语法突出显示在Github Markdown
- /dist目录在开源项目中的意义是什么?
- 我如何从现有回购的分支创建一个新的GitHub回购?
- 在git中压缩提交是什么意思?
- 如何在GitHub上找到存储库项目的创建日期?
- 如何设置一个git项目使用外部回购子模块?
- 强制LF eol在git的回购和工作副本
- 防止在GitHub上推送到master ?
- 我如何在github上引用特定问题的评论?
- 我如何才能看到我在Github上看到的所有问题?