user3715648 user3715648 -4 years ago 126
Git Question

Is it possible to clone a git repo without the .git folder, into an existing non empty directory

I have an odd use case, and am not very familiar with Git. I have two git repos; repo one which is empty, and repo two which has files. I also have a folder ./foo. I want something similar to this:

cd ./foo
git clone repo_one .
git clone repo_two . (I just want the files from repo_two. No .git folder or anything)
git add --a
git push repo_one

or maybe

cd ./foo
git clone repo_two .
rm ./.git
git clone repo_one . (possible in an existing directory though?)

Are either of these possible? All I really care about is the end result; that .foo is linked to repo_one, but contains the files from repo_two.

Answer Source

Since you've cloned both the Git repos, execute the following command on repo #2 to export (or archive) it without its .git folder:

git archive master | tar -x -C /path/inside/repo1

The final sequence of events would be something like this:

cd foo
git clone repo_one
git clone repo_two
cd repo_two
git archive master | tar -x -C ../repo_1
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download