通过 GitHub Web 应用程序直接将新文件上传到 Git 存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10318403/
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
Uploading new files to a Git repository directly through the GitHub web application
提问by MRocklin
It is possible to directly edit files in a repository stored on GitHub through the web interface. Most of us would never do this but it has its uses.
可以通过 Web 界面直接编辑存储在 GitHub 上的存储库中的文件。我们大多数人永远不会这样做,但它有它的用途。
I teach an introductory level course. I'd like to use Git and GitHub for homework distribution and collection (GitHub offers free private accounts for education). However, I can't ask completely fresh students to learn Git, at least not in the first few weeks. For the first few weeks I would like to say
我教一门入门级课程。我想使用 Git 和 GitHub 来分发和收集作业(GitHub 提供免费的教育专用帐户)。但是,我不能要求完全新生的学生学习 Git,至少在最初几周不能。在最初的几周里,我想说
"You can upload your homework by clicking on this sequence of buttons on github.com"
“你可以通过点击 github.com 上的这一系列按钮来上传你的作业”
and then eventually teach them how to use the command line.
然后最终教他们如何使用命令行。
Ideally I'd like for them to be able to upload new files, not just edit existing ones. I can't find a way to do this though. How can I use the GitHub web interface for a similar purpose?
理想情况下,我希望他们能够上传新文件,而不仅仅是编辑现有文件。我找不到办法做到这一点。如何将 GitHub Web 界面用于类似目的?
采纳答案by MRocklin
Note that since early December 2012, you can create new files directly from GitHub:
请注意,自 2012 年 12 月上旬以来,您可以直接从 GitHub创建新文件:
ProTip?: You can pre-fill the filename field using just the URL.
Typing?filename=yournewfile.txt
at the end of the URL will pre-fill the filename field with the nameyournewfile.txt
.
专家提示?:您可以仅使用 URL 预填充文件名字段。在 URL 末尾
键入?filename=yournewfile.txt
将使用 name 预填充文件名字段yournewfile.txt
。
回答by VonC
Since February 2016, you can add/create/uploadnew files from the GitHub web interface.
自 2016 年 2 月起,您可以从 GitHub Web 界面添加/创建/上传新文件。
See "Upload files to your repositories ":
请参阅“将文件上传到您的存储库”:
You can click the “Upload files” button in the toolbar at the top of the file tree.
您可以单击文件树顶部工具栏中的“上传文件”按钮。
Or, you can drag and drop files from your desktop onto the file tree.
或者,您可以将文件从桌面拖放到文件树上。
This replaces the file creation described in the 2012 answer, and add the upload capability (for one or several files).
这取代了2012 回答中描述的文件创建,并添加了上传功能(针对一个或多个文件)。
回答by Fred Foo
I think using gist.github.comis the easiest option. Each gist is a Git repository that can be accessed from the web browser or from the shell, there's a comment button, and although gists are usually single files, they can hold multiple files.
我认为使用gist.github.com是最简单的选择。每个 gist 都是一个 Git 存储库,可以从 web 浏览器或 shell 访问,有一个评论按钮,虽然 gist 通常是单个文件,但它们可以包含多个文件。
The drawbacks to gists are obviously the cryptic URLs and the fact that you have to copy-paste file contents into the browser unless you use a separate tool.
要点的缺点显然是神秘的 URL,而且除非您使用单独的工具,否则您必须将文件内容复制粘贴到浏览器中。
回答by asmeurer
If you just need to have them edit the same files (assumedly through the web interface), you could create a skeleton repository with empty or basic files, and then have the students fork that.
如果您只需要让他们编辑相同的文件(假设是通过 Web 界面),您可以创建一个包含空文件或基本文件的骨架存储库,然后让学生分叉。
回答by Tom Salles
If you start a new project without a README file, it won't show.
如果您在没有 README 文件的情况下启动一个新项目,它将不会显示。
You need at least one file in it. As it's shown in previous answers, you can drag your files or select it using finder or file explorer.
您至少需要一个文件。正如之前的答案中所示,您可以拖动文件或使用查找器或文件资源管理器选择它。