Download a specific branch of a github project
Asked Answered
G

5

19

To cut the story short, to run a convolutional neural network model, I need an special version of nolearn, which has a url of the form https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn . However, there are no Download as Zip buttons at the page, nor I can download it with

git clone https://github.com/dnouri/nolearn -branch 1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn

Simply,

git clone https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn

does not work, too.

Even, I have no idea what should I search for in Google!

Note: This is the last version which provided support for the class Objective, i.e. the command from lasagne.objectives import Objective is no more supported!

Gamache answered 1/9, 2015 at 20:28 Comment(0)
S
13

Other than in Subversion (SVN), git has separate namespaces for directories (file system folders), branches and tags. Thus https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn is not, per se, a branch. 1659e4811e498dc1f442d8e6486d0831f85255b4 is a commit ID, used here to refer to the revision created by the commit. dnouri/nolearn is the repository name on GitHub (repository nolearn on account dnouri) and the final nolearn in the URL is a directory within the content of revision 1659e4811e498dc1f442d8e6486d0831f85255b4.

The 'normal' way to get this code with git would be:

  1. replicate the repository to your local machine

    git clone https://github.com/dnouri/nolearn.git
    

    (You can find this URL on the repository's page https://github.com/dnouri/nolearn, in the 'clone URL' field.)

  2. enter the local repository

    cd nolearn
    
  3. check out the wanted revision

    git checkout 1659e4811e498dc1f442d8e6486d0831f85255b4
    
  4. change into the respective directory inside the repository

    cd nolearn
    
Santana answered 1/9, 2015 at 20:48 Comment(2)
it's less data consuming by using @mayo's answer: git clone <url> --branch <branch> --single-branch <folder>Bezanson
That's true @RicoNeitzel, but AFAIK it's not what Git users would usually do, unless the amount of data really is a problem. (And if so, one should probably consider whether all that data really belongs into a single Git repo.)Santana
G
45

This can help you:

How to clone a single branch in git?

Where specifies:

git clone <url> --branch <branch> --single-branch [<folder>]

Docu :

Git Clone

--[no-]single-branch

Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at. When creating a shallow clone with the --depth option, this is the default, unless --no-single-branch is given to fetch the histories near the tips of all branches. Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.

Gosselin answered 1/9, 2015 at 20:39 Comment(2)
Note to other noobs like me, the folder name in the command above should not be inside square brackets.Perpetual
Good point! I am not sure but it seems like a convention from i-dont-know-where that square brackets mean an optional parameter.Gosselin
S
13

Other than in Subversion (SVN), git has separate namespaces for directories (file system folders), branches and tags. Thus https://github.com/dnouri/nolearn/tree/1659e4811e498dc1f442d8e6486d0831f85255b4/nolearn is not, per se, a branch. 1659e4811e498dc1f442d8e6486d0831f85255b4 is a commit ID, used here to refer to the revision created by the commit. dnouri/nolearn is the repository name on GitHub (repository nolearn on account dnouri) and the final nolearn in the URL is a directory within the content of revision 1659e4811e498dc1f442d8e6486d0831f85255b4.

The 'normal' way to get this code with git would be:

  1. replicate the repository to your local machine

    git clone https://github.com/dnouri/nolearn.git
    

    (You can find this URL on the repository's page https://github.com/dnouri/nolearn, in the 'clone URL' field.)

  2. enter the local repository

    cd nolearn
    
  3. check out the wanted revision

    git checkout 1659e4811e498dc1f442d8e6486d0831f85255b4
    
  4. change into the respective directory inside the repository

    cd nolearn
    
Santana answered 1/9, 2015 at 20:48 Comment(2)
it's less data consuming by using @mayo's answer: git clone <url> --branch <branch> --single-branch <folder>Bezanson
That's true @RicoNeitzel, but AFAIK it's not what Git users would usually do, unless the amount of data really is a problem. (And if so, one should probably consider whether all that data really belongs into a single Git repo.)Santana
S
5

This is the link to the .zip : https://github.com/dnouri/nolearn/archive/1659e4811e498dc1f442d8e6486d0831f85255b4.zip

Scheme answered 1/9, 2015 at 20:31 Comment(7)
Thanks for the reply, however, this is not the one I need! This is the latest version on master branch, not the one I need.Gamache
That should work, I've inserted the right link:github.com/dnouri/nolearn/archive/…Scheme
Thanks. It just worked. However, I wonder if there are any git hacks around?Gamache
Git hacks? What do you mean?Scheme
I mean some switches in the command line, e.g. git clone https://github.com/dnouri/nolearn --some-magic-switch 1659e4811e498dc1f442d8e6486d0831f85255b4Gamache
@Das-g mentioned the 'magic switch' you're looking for and the reason you couldn't download it.Scheme
Thanks! For everyone that uses Github and not the git CLI, I've found that the URL https://github.com/<username>/<repository>/archive/<branch>.zip will download that branch.Pleuro
A
3

The solution for zip that would work for any repo and branch:

https://github.com/<username>/<repository>/archive/<branch>.zip
Allogamy answered 3/7, 2023 at 21:0 Comment(0)
E
0

You can download a snapshot of any branch, tag, or specific commit from GitHub.com. Source code archives are available at specific URLs for each repository. For example, consider the repository github/codeql There are different URLs for downloading a branch, a tag, or a specific commit ID.

Branch - main - https://github.com/github/codeql/archive/refs/heads/main.tar.gz

Tag - codeql-cli/v2.12.0 - https://github.com/github/codeql/archive/refs/tags/codeql-cli/v2.12.0.zip

Commit - aef66c4 -https://github.com/github/codeql/archive/aef66c462abe817e33aad91d97aa782a1e2ad2c7.zip

Patch - https://github.com/repo/codeql/pull/pull-id.patch

You can use either .zip or .tar.gz in the URLs above to request a zipball or tarball respectively.

Exchangeable answered 11/1 at 12:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.