Git init inside a folder of a git repository by mistake

1

I have a git repository with different folders. By mistake I made a git init within one and continued working as if nothing happened, but saving the modifications in a subdirectory of the main program. Now I have two different git, each of them with a different branch Master and Branch and I would like to do a merge keeping only the initial git without having to give up all the commits of the younger git. A scheme would be:

  • Program:
    • .git
    • Directory
      • .git
      • Codes

I would be very grateful if someone knew how to fix it. Greetings!

    
asked by Jamil KR 13.09.2018 в 11:08
source

2 answers

0

The entire git system is based on the hidden .git directory, which contains the files, incrementals, index references and so on ...

I understand from your comment that you want to keep the project that is in the DIRECTORY, so I think you have it easy:

  • moves DIRECTORY to the PROGRAM level
  • delete the PROGRAM directory
  • rename DIRECTORY by PROGRAM

You do not need to walk with merges, since what you need is to have your project at a higher level. Only move directories (with their content, of course)

    
answered by 13.09.2018 в 11:19
0

Depending on the point where you are, you can choose one solution or another ... but it is a very convoluted situation.

If it is positioned in the parent directory and does an add , you should be notified of a warning that you are adding an embedded repository to the principal. In this situation, to preserve the entire history of the nested repository, a possible strategy to follow would be to create a branch in the parent and insert the child repository into it in the form of a submodule. It is a process that is sure to be better explained in the documentation .

Then it would be time to proceed with the merger of that branch created and the main one.

However, as I comment, everything depends on the exact state of the repository.

    
answered by 13.09.2018 в 14:13