Aerodynamika
Aerodynamika

Reputation: 8413

How to create an independent git repository in a folder within a different git repository?

I have a git repository in folder AAA and then another git repository in folder BBB.

What I need to do is to create a new folder in AAA where I would copy BBB repository, so it would become a subfolder of AAA.

The result should be that AAA repository stays as it is and excludes BBB folder, while when I enter the BBB folder it's a new repository of its own that has nothing to do with AAA.

Could you please explain me how to do that?

As I understand, I probably could create subfolder BBB in AAA then add it to .gitignore and then initialize a new repo there? Right? How would I do that? Thank you!

Upvotes: 1

Views: 414

Answers (1)

Klas Mellbourn
Klas Mellbourn

Reputation: 44377

This is the absolute minimum that you would need to do

git init AAA
cd AAA
echo BBB > .gitignore
git init BBB

For most scenarios submodules is a better solution. But if you want the repositories to be completely independent of each other, this is a way to do it.

Upvotes: 3

Related Questions