0

With the git clone command and arguments --depth/--branch, you can download the last commit of a specific repository branch, but how to download a specific commit using its hash?

P.S. The use of git clone and git checkout hash is not suitable, because in that case necessary to make a clone of the entire repository.

Thanks!

Tagor
  • 1
  • 3
  • Possible duplicate of [How to clone git repository with specific revision/changeset?](https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset) – Damien MATHIEU Jul 04 '17 at 13:41
  • If you don't want to use `git clone` nor `git checkout hash` what do you mean by "download specific commit"? Does it mean *get full code on specific state* or *get only diff between specific commit and previous one* or something else? – running.t Jul 04 '17 at 13:48
  • @DamienMATHIEU In the variant that you proposed, you also use the method that downloads the entire repository – Tagor Jul 04 '17 at 13:52
  • @running.t This means that I'm getting the full code of a specific commit and nothing more, no history of the repository commits. – Tagor Jul 04 '17 at 13:55
  • Apart from using the shallow clone which you've already suggested, the only other way i can think of downloading a specific commit is by going to github and navigating to the particular commit you are after and then just downloading the files raw - that way you are not downloading the full repo history. but then again, you're not actually downloading the repository but a file. i'd simply clone the repository and then checkout the particular hash you are after and do the work. i can't see a reason to do otherwise because computers these days can handle the memory – BenKoshy Jul 04 '17 at 14:36

1 Answers1

0

If the repo is in github, you can navigate to the tree view of the repo at https://github.com/<repo_name>/tree/<commit_sha>

Then clicking on the Download ZIP button on the right-hand navigation bar will download the repo up to the specified commit.

ehmon
  • 151
  • 1
  • 10
  • I know this way, it's not suitable because it's not only downloading github – Tagor Jul 04 '17 at 16:57
  • could try `git clone https://github.com//tree/` or you could make a branch that is set to the desire commit and then clone the branch. – ehmon Jul 04 '17 at 17:05