0

I want to copy the contents of a git repository to another repository inside a folder.

SourceRepo/ -A -B

TargetRepo -C -D folder/

i want to move (A,B) inside folder/ with branch and commit history.

Please help.

yogas
  • 189
  • 1
  • 3
  • 17
  • Possible duplicate of [How do you merge two Git repositories?](https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories) – Calum Halpin Oct 06 '19 at 10:41

1 Answers1

0

The git subtree command does exactly what you want. Execute the following command on TargetRepo in the branch you want to add it to:

git subtree add --prefix=folder <git-url-of-SourceRepo> master

This will add SourceRepo's master branch inside folder in your TargetRepo.

David Sugar
  • 1,042
  • 6
  • 8