0

So I have a Git repo with the following folder structure:

A/B/C1
    C2

The first dozens of commits were done in folder C1 and then C2 was created and the C1 contents were copied over and work continued in C2.

What I now want is just one folder C in the repo's root with the combined history of the former subfolders C1 and C2. No A, no B and no C1 or C2.

Any idea how to achive this?

  • 4
    Is there a problem with just moving them into a new folder and committing your changes? – Calum Halpin Sep 26 '19 at 15:17
  • Since we are building tools for automated testing we would like to have them work on the old revisions as well. So a unified structure would be prefered. –  Sep 26 '19 at 15:43
  • What do you mean by a "unified structure"? Git doesn't track history by directory, it does it by repositories and files. If you move the contents of folders C1 and C2 to C then git will track that history and be able to show you the history of those files back to when they were created in their original folders but obviously they will now have moved. – Calum Halpin Sep 26 '19 at 16:12
  • The files in C1 and C2 are the same. So I would copy the contents of C2 and delete C1. Since C1 was copied over to C2 without Git knowing (new files added), their history would be cutt off then. So I thought I might as well fix that now. –  Sep 27 '19 at 06:52

1 Answers1

0

You can just delete C1. Git doesn't actually track file renames/moves anyway. If you want to see the full history of a file in C2 you'll need to use git log --follow <path> regardless of whether or not you delete C1.

See this question.

Calum Halpin
  • 1,945
  • 1
  • 10
  • 20