Like spare-checkout, do we have a command like sparse-fetch ?

As we know we have sparse-checkout to sparsely checkout files + folders which are required but there is a catch as it needs a _“git fetch” _which get everything from github repo and puts into .git folder and sparse-checkout just pulls out data from this .git folder

Is there a way to avoid git fetch for a sparse-checkout, so instead of getting everything in .git folder we only fetch what we want.

Please don’t advice _“git archive” _as this command doesn’t work very well due to permission issues, but still if one has good solution around this command I welcome it.

Thanks

Rahul Kunwar

This is a good question.

I don’t think there is.

I found this explantion for the lack of the feature reasonable:

Git is a system designed to remember every change to the tracked files in a repository. Once a file goes in, it’s there for good since it becomes part of the log history (unless you slice and dice it with filter-branch, but that has side-effects). Since remembering your files and their content is a primary feature, git doesn’t currently have the ability to clone just a subfolder (which would save bandwidth). However, git does have the ability to checkout a subset of the repo, like a subfolder. This is what’s referred to as a “sparse checkout”.

Source: http://phatblat.com/git/tricks/2014/09/14/git-sparse-checkout.html

I guess currently the only work around would be to manually copy and paste the file from GitHub, but I understand that’s not what you are asking for: 

https://www.quora.com/How-can-I-pull-one-file-from-a-Git-repository-instead-of-the-entire-project/answer/Supun-Budhajeewa