A Bitbucket subscriber writes:
Hi,
I want to be able to pull only a specific file folder from the repo after
I have done a git init in a particular folder on my local machine.
I have several hundred folders from which I am interested in only one at atime for a deployment.
However, I have not been able to come across any git command that enables
me to do so.
It's important to remember that every time you clone or checkout a repository, a full copy of (at least) the entire repository's state at the specified commit is delivered to your machine.
Considering that, you can do the following:
git clone <repo-url> --depth 1 --bare git --work-tree=/path/to/checkout checkout HEAD -- sub/directory
The first line will clone the full current state of your repository, omitting any history, without creating a work-folder.
The second line unpacks the folder desired.
We strongly recommend making any commits to the files in this state; it's much better to work on a full copy of a working directory.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.