0

I have a repository for a_project with git repository set up, but I just realized that in a sub-directory of a_project/src, I have another git repository. I'd like to merge a_project/src's .git data (history, branches, etc.) into that of a_project.

My purpose to merge them together is that I noticed that I cannot commit changes to files in src. The changes cannot be staged:

Unstaged changes (1)
modified   src/snmp_trap_processing
@@ -1 +1 @@
-Subproject commit 99ef96f28d4f74bc671ca6b2da97ecf50b84f833
+Subproject commit 581414eecb3db4bc1e572d57d1d1f8788675c372

I've studied in StackOverflow. The closest case is to move a repository from a subdirectory to the parent. But where the parent has no existing git repository tracking, for example, https://stackoverflow.com/a/3247756/126164 The instruction there, in my case, a_project/src's .git will destroy the .git tracking at the parent directory, a_project.

So I wonder if there is a way to merge between the two .git instead of overriding one .git over the other?

EDIT:

I realize that in a_project/src the .git is just a file with the content below:

cat .git
gitdir: ../../.git/modules/src

So it might not be as complicated as I thought. Maybe, I can just remove the a_project/src/.git then it will be fine? Maybe, also remove the submodule setup for a_project/src in a_project/.git ?

Yu Shen
  • 2,770
  • 3
  • 33
  • 48
  • Does this answer your question? [git repo inside a repo](https://stackoverflow.com/questions/67780789/git-repo-inside-a-repo) – matt Jun 04 '21 at 01:54
  • @matt That removes history and branches. – phd Jun 04 '21 at 09:17

0 Answers0