Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a git repository in a parent folder of another git repository and removing the child repository but integrating its history into the parent

Tags:

git

repository

I have the following folder structure:

foo/
foo/bar
foo/baz
foo/bee

I created a git repository on foo/bar/.git.

I realized later on that I needed to include all the other directories in foo in a git repository, so I created a git repository on foo/.git.

foo/.git
foo/bar/.git
foo/baz
foo/bee

I could just delete foo/bar/.git but I want to be able to keep the history of that git repository but within foo/.git instead of foo/bar/.git.

I was trying to read on submodules but if I understand correctly it is a way to integrate a version of an existing repository as a subtree of your own repository.

I'm not entirely sure this is what I need. I don't need to keep foo/bar/.git. I want the foo/.git to be my main repository. I just wanted to know if there was a way to keep or integrate the history of the foo/bar/.git within foo/.git so I could remove foo/bar/.git.

like image 737
stormwild Avatar asked May 03 '12 10:05

stormwild


People also ask

Can I create Git repository inside another?

Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This lets you clone another repository into your project and keep your commits separate.


1 Answers

You are looking for subtree merging

Github's help has a good guide on this, and there's a chapter in Pro Git on this, same with the Git Community book

like image 100
dbr Avatar answered Nov 12 '22 06:11

dbr