user3715648
user3715648

Reputation: 1588

Pull just the content of a repo into a folder?

I'm working with Git programmatically. I have two repos, A and B. I want to clone A into a dir "./foo", then get just the contents of repo B into "./foo". So ./foo will be linked to repo A, but have all the files from both.

Is there any efficient way to do this? Right now, my pattern looks like this:

clone repoA into ./foo
clone repoB into a temp directory
delete .git from temp directory
copy contents of temp directory into ./foo

This works, but is a little slower than i'd like. Any better way?

Upvotes: 0

Views: 37

Answers (1)

Anthony Geoghegan
Anthony Geoghegan

Reputation: 11983

Since you’re only interested in the file contents of Repo B, I would suggest that when you’re cloning it, you use the --depth option to copy only the most recent commit:

git clone --depth 1 repoB.url /path/to/tmp/dir

This creates a shallow clone of the repository and not having to download all the other commits will greatly speed up the cloning.

Upvotes: 1

Related Questions