0

Is there a way to fetch / pull upto a specific revision of a repository?

The reason for the requirement is that I haven't pulled from this GitHub repository for a long time and now my internet connection (it's a decent broadband connection!) is having trouble dealing with this large sized fetch and keeps failing again and again.

I now want to try and fetch in steps - so that I keep making fetch progress across multiple attempts.

Is it possible? Any help will be highly appreciated.

Roshan
  • 220
  • 3
  • 11

1 Answers1

0

Yes, you can. First call this to see which commit you want to pull from first.

git log

Then call this:

git fetch origin 96de5297df870:refs/remotes/origin/foo-commit

This will download only the commit of that ID 96de5297df870 (and its ancestors that you miss), and store it as (non-existing) remote branch origin/foo-commit.

adao7000
  • 3,462
  • 2
  • 25
  • 35
  • Could u pls share what's the role of the non-existing remote branch here? – Roshan Jul 08 '15 at 14:19
  • Yeah, that just creates a new branch in your local repo. Then you can merge or checkout. See http://stackoverflow.com/questions/14872486/pull-a-specific-commit-from-a-remote-git-repository – adao7000 Jul 08 '15 at 14:21
  • It doesn't work for me (seems like it hasn't worked for others too - http://stackoverflow.com/questions/16795813/git-pull-from-remote-can-i-pull-a-specific-commit). I keep getting "Couldn't find remote ref ......". Kindly let me know if I missed understanding something in your solution? – Roshan Jul 08 '15 at 14:35
  • http://stackoverflow.com/questions/14370157/git-fetch-a-specific-commit-by-hash says "According to the manual, git fetch wants a refspec, the simplest form of which is a ref, and a bare SHA-1 isn't a ref. I.e., the commit has to have a name (branch, tag) on the remote for you to be able to fetch it." Is that why it doesn't work? – Roshan Jul 08 '15 at 14:38
  • Is this a repo you have previously cloned? – adao7000 Jul 08 '15 at 14:43
  • yes, cloned but not pulled / fetched from for some time now. – Roshan Jul 08 '15 at 14:47
  • are you trying to fetch from a specific branch? – adao7000 Jul 08 '15 at 14:49
  • trying to fetch from master. I want to bring my master branch up-to-date but unable to do so due to large-size downloads involved. So, hoping to do it in parts - by moving upto a specific commit at a time. – Roshan Jul 08 '15 at 14:50