1

Newbie at git, but I've been trying to figure this out for an hour. How do I clone a specific release from github?

I want these files: https://github.com/angular-ui/ui-grid.info/tree/gh-pages/release/3.1.1 but that URL does not work with clone, so I can't figure out how to get them.

I can clone this parent URL: https://github.com/angular-ui/ui-grid.info.git but that does not seem to have the files I want.

So how can I get that specific 3.1.1 release?

UPDATE: Issue solved. My question assumed that git allows you to clone a specific directory in the repo (and not have to also clone all the other directories you don't care about). I now realize git just doesn't support that; you apparently have to clone the entire repo and then just cd into the directory you want.

user2543623
  • 1,452
  • 2
  • 15
  • 24

2 Answers2

1

Release v3.1.1 is essentially a tag. You can clone using that tag:

git clone --branch v3.1.1 https://github.com/angular-ui/ui-grid.info.git

Or

git clone --branch v3.0.5 https://github.com/angular-ui/ui-grid.info.git

To clone "Release 3.0.5"

See How to git clone a specific tag

Community
  • 1
  • 1
K'Prime
  • 98
  • 4
  • Thanks, but no, that does not give the same files as shown on https://github.com/angular-ui/ui-grid.info/tree/gh-pages/release/3.1.1 That clone command is cloning a bunch of other files. How can I get those files exactly? – user2543623 Feb 14 '16 at 13:57
  • @user2543623 After cloning you checkout gh-pages branch at the commit that you want. How? Please search – Aseem Bansal Feb 14 '16 at 16:09
  • @AseemBansal -- Thanks, but no, I already tried that and that isn't the right answer either. "git checkout gh-pages" still gives a different set of files than is shown on https://github.com/angular-ui/ui-grid.info/tree/gh-pages/release/3.1.1 Is there any way to get exactly those files? – user2543623 Feb 14 '16 at 16:51
  • @user2543623 What's the difference? The release is a folder inside it and you have to manually go there. What is the current commit hash that is checked out? http://stackoverflow.com/questions/949314/how-to-retrieve-the-hash-for-the-current-commit-in-git Is it same as the one on github for the content that you want? – Aseem Bansal Feb 14 '16 at 16:58
  • Oh, I think I get it -- git simply doesn't support fetching only that one directory I want; it will always fetch every other directory under the root too, even though I don't need those. That's what I was not understanding. I though I could just clone that github sub-directory URL directly. But OK, I get it now. Thanks for the help. – user2543623 Feb 14 '16 at 17:24
0

You can clone anything you want with GIT.
Branches tags, commit and so on.

You simply have to pass the right parameter to the clone command.

Gow to clone specific branch? (-b flag)

# use the -b flag to clone a specifc branch 
git clone -b <branch> <remote_repo>

--single-branch flag

--[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.

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.


git checkout tags/<tag name>

Clone the repo and then checkout the desired tag:

# Checkout specific tag and create branch with the desired name
git checkout tags/<tag_name> -b <tag_name>
CodeWizard
  • 128,036
  • 21
  • 144
  • 167