Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clone/fetch a repo getting only the history

Tags:

git

Is it possible to download a repository's commits, branches, and tags, excluding blobs and trees? I would like to be able to view the history and whatnot without downloading the files (this is for the Chromium repo, which is multiple gigs). Obviously I will not be able to see which files were affected by a commit, but that's fine.

like image 299
Sally Richter Avatar asked Jun 07 '16 15:06

Sally Richter


People also ask

Does git clone get all history?

Cloning an entire repo is standard operating procedure using Git. Each clone usually includes everything in a repository. That means when you clone, you get not only the files, but every revision of every file ever committed, plus the history of each commit.

How do I clone a git repository without history?

i.e. if you just want the latest commit use git clone --depth 1. branch is the name of the remote branch that you want to clone from. i.e. if you want the last 3 commits from master branch use git clone --depth 3 -b master. repo_url is the url of your repository.

When you clone a repo do you get all the branches?

When you clone a repository, you don't get one file, like you may in other centralized version control systems. By cloning with Git, you get the entire repository - all files, all branches, and all commits.


2 Answers

No, or at least, not using any ordinary access. Some sites offer web access, through which you can obtain the contents of every commit object without also obtaining tree and blob objects, but the normal process of receiving objects or thin packs is either truncated at the commit level (via --depth) or is complete.

You can of course see all visible tags with git ls-remote as well as through any sensible web interface (it would be weird to provide something like GitHub's fancy API if you didn't provide the tags that way :-) ).

Note that traversing all commits via a web API may be tremendously slow, either due to having to stop and wait (if you program it synchronously rather than as a streaming process) or due to rate limiting software on the host (GitHub and Bitbucket both seem to do rate limiting).

like image 106
torek Avatar answered Nov 15 '22 21:11

torek


We are building ghuser.io (enhanced GitHub profile pages) and any way to get the commit history without files would help us tremendously to scale.

Then you would need to setup a mirror server with GVFS (Git Virtual File System) / VFS For Git support.

Since June 2016 (the OP question) and now (Q4 2018), VFS For Git (since issue 72 is soon to be resolved) has been proposed by Microsoft (Feb. 2017), and allows you to develop with TeraBytes repos(!) without having the files downloaded.

GitHub itself should support it soon.

See more at gvfs.io, although I suspect that a domain name which is now renamed to reflect the new "VFS For Git" name: https://vfsforgit.org.
(Microsoft/VFSForGit.WWW issue 9 is closed, Nov. 28th 2018)

Note: (Feb. 2021), the certificate issue regarding https://vfsforgit.org finally got resolved: see microsoft/VFSForGit issue 1705.

like image 21
VonC Avatar answered Nov 15 '22 21:11

VonC