0

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?

2
  • Would submodules work here? Commented Nov 9, 2017 at 20:56
  • The contents of a repo are commits (which are the history of the repository). The description you give is about files, i.e., one commit; so that's not really getting the contents of B into A. Which do you want? Commented Nov 9, 2017 at 21:08

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow! Fastest acceptance ever! Are you sure you don't want to wait and see if someone comes up with something better?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.