git 下载 GitHub 项目的最快方法

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6466945/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:15:09  来源:igfitidea点击:

Fastest way to download a GitHub project

gitgithub

提问by Kannan Ekanath

I need to download the source code of the project Spring data graph exampleinto my box. It has public read-only access. Is there is an extremely fast way of downloading this code?

我需要将项目Spring 数据图示例的源代码下载到我的框中。它具有公共只读访问权限。是否有一种非常快速的下载此代码的方法?

I have no idea of working on GitHub/committing code and most tutorials out there on the web seems to assume that "I would want to setup a project in GitHub" and inundate me with 15-20 step processes. To me, if a source repository is available for the public, it should take less than 10 seconds to have that code in my filesystem.

我不知道在 GitHub 上工作/提交代码,网络上的大多数教程似乎都假设“我想在 GitHub 中设置一个项目”并用 15-20 个步骤流程淹没我。对我来说,如果源存储库可供公众使用,那么在我的文件系统中包含该代码应该需要不到 10 秒的时间。

Tutorials that provide me with 15-20 step processes:

为我提供 15-20 步流程的教程:

I need something very very very simple. Just pull the source code, and I am more interested in seeing the source code and not learn GitHub.

我需要一些非常非常非常简单的东西。直接拉源码,我更感兴趣的是看源码而不是学习 GitHub

Are there any fast pointers/tutorials? (I have a GitHub account.)

是否有任何快速指针/教程?(我有一个 GitHub 帐户。)

回答by jncraton

When you are on a project page, you can press the 'Download ZIP' button which is located under the "Clone or Download" drop down:

当您在项目页面上时,您可以按位于“克隆或下载”下拉菜单下的“下载 ZIP”按钮:

enter image description here

在此处输入图片说明

This allows you to download the most recent version of the code as a zip archive.

这允许您下载最新版本的代码作为 zip 存档。

If you aren't seeing that button, it is likely because you aren't on the main project page. To get there, click on the left-most tab labeled "<> Code".

如果您没有看到该按钮,可能是因为您不在主项目页面上。要到达那里,请单击标有“<> 代码”的最左侧选项卡。

回答by unwind

You say:

你说:

To me if a source repository is available for public it should take less than 10 seconds to have that code in my filesystem.

对我来说,如果源存储库可供公众使用,那么在我的文件系统中包含该代码应该需要不到 10 秒的时间。

And of course, if you want to use Git (which GitHub is all about), then what you do to get the code onto your system is called "cloning the repository".

当然,如果您想使用 Git(GitHub 就是它的全部内容),那么您将代码放到系统上的操作称为“克隆存储库”。

It's a single Git invocation on the command line, and it will give you the code just as seen when you browse the repository on the web (when getting a ZIP archive, you will need to unpack it and so on, it's not always directly browsable). For the repository you mention, you would do:

这是命令行上的单个 Git 调用,它将为您提供与您在 Web 上浏览存储库时看到的代码一样(获取 ZIP 存档时,您需要解压缩它等等,它并不总是可以直接浏览的) )。对于您提到的存储库,您可以执行以下操作:

$ git clone git://github.com/SpringSource/spring-data-graph-examples.git

The git:-type URL is the one from the page you linked to. On my system just now, running the above command took 3.2 seconds. Of course, unlike ZIP, the time to clone a repository will increase when the repository's history grows. There are options for that, but let's keep this simple.

git:型网址为您链接到页面中的一个。刚才在我的系统上,运行上述命令需要 3.2 秒。当然,与 ZIP 不同的是,随着存储库历史记录的增长,克隆存储库的时间也会增加。有很多选择,但让我们保持简单。

I'm just saying: You sound very frustrated when a large part of the problem is your reluctance to actually use Git.

我只是想说:当问题的很大一部分是您不愿意实际使用 Git时,您听起来很沮丧。

回答by Manav Kataria

Updated July 2016

2016 年 7 月更新

As of July 2016, the Download ZIPbutton has moved under Clone or download to extreme-rightof header under the Codetab:

截至2016年7月,在Download ZIP按钮下方移动Clone or download 极右的标题下方的Code标签:

Download ZIP (2013)

下载 ZIP (2013)



If you don't see the button:

如果您没有看到按钮:

  • Make sure you've selected <> Codetab from right side navigation menu, or
  • Repo may not have a zip prepared. Add /archive/master.zipto the end of the repository URL and to generate a zipfile of the master branch.

    http://github.com/user/repository/

  • 确保您<> Code已从右侧导航菜单中选择选项卡,或
  • Repo 可能没有准备好 zip。添加/archive/master.zip到存储库 URL 的末尾并生成 master 分支的 zipfile。

    http://github.com/user/repository/

-to-

-到-

http://github.com/user/repository/archive/master.zip

to get the master branch source code in a zip file. You can do the same with tags and branch names, by replacing masterin the URL above with the name of the branch or tag.

获取 zip 文件中的 master 分支源代码。您可以对标签和分支名称执行相同的操作,方法是将master上面的 URL替换为分支或标签的名称。

回答by purezen

Another faster way of downloading a GitHub project would be to use the clone functionality with the --depthargument as:

下载 GitHub 项目的另一种更快方法是使用带有--depth参数的克隆功能:

git clone --depth=1 [email protected]:organization/your-repo.git

to perform a shallow clone.

执行浅克隆。

回答by YeHtunZ

Downloading with Git using Windows CMD from a GitHub project

使用 Windows CMD 从 GitHub 项目通过 Git 下载

You can get download the link from GitHub <b>HTTPS clone URL</b>

您可以从 GitHub <b>HTTPS clone URL</b>获取下载链接

Download with Window Command Prompt cmd for above picture HTTPS clone URL

使用Window Command Prompt cmd下载上图HTTPS克隆URL

  1. Copy the HTTPS clone URLshown in picture 1

  2. Open CMD

  3. git clone //paste the URL show in picture 2

  1. 复制图 1 所示的HTTPS 克隆 URL

  2. 打开命令

  3. git clone //paste the URL show in picture 2

回答by Jonathan L

Use

git clone https://github.com/<path>/repository
or
git clone https://github.com/<path>/<master>.git

examples

例子

git clone https://github.com/spring-projects/spring-data-graph-examples
git clone https://github.com/spring-projects/spring-data-graph-examples.git

回答by Richard Le Mesurier

There is a new (sometime pre April 2013) option on the site that says "Clone in Windows".

网站上有一个新的(2013 年 4 月之前的某个时间)选项,上面写着“在 Windows 中克隆”。

This works very nicely if you already have the Windows GitHub Client as mentioned by @Tommy in his answeron this related question (How to download source in ZIP format from GitHub?).

如果您已经拥有@Tommy 在他对这个相关问题的回答中提到的 Windows GitHub 客户端(如何从 GitHub 下载 ZIP 格式的源代码?),这将非常有效。

回答by Udhav Sarvaiya

I agree with the current answers, I just wanna add little more information, Here's a good functionality

我同意当前的答案,我只想添加更多信息,这是一个很好的功能

if you want to require just zip file but the owner has not prepared a zip file,

如果您只需要 zip 文件,但所有者尚未准备好 zip 文件,

To simply download a repository as a zip file: add the extra path /zipball/master/to the end of the repository URL, This will give you a full ZIP file

要简单地将存储库下载为 zip 文件:将额外的路径/zipball/master/ 添加到存储库 URL 的末尾,这将为您提供完整的 ZIP 文件

For example, here is your repository

例如,这是您的存储库

https://github.com/spring-projects/spring-data-graph-examples

https://github.com/spring-projects/spring-data-graph-examples

Add zipball/master/in your repository link

在您的存储库链接中添加zipball/master/

https://github.com/spring-projects/spring-data-graph-examples/zipball/master/

https://github.com/spring-projects/spring-data-graph-examples/zipball/master/

Paste the URL into your browser and it will give you a zip file to download

将 URL 粘贴到您的浏览器中,它将为您提供一个 zip 文件以供下载