1

I've read several threads on moving directories between git repositories, and the one I've settled on using is this one, which makes use of git subtree.

Following the steps, everything seems to work well, but the problem comes at the end.

I'm left with a new repo where all of the contents of the directory I wanted to move is in the root. If I do a git mv of the contents into the subdirectory I want, when I do a git log -- sub\dir\1, the history is NOT viewable from there. The history is only visible from the root.

I plan to move multiple directories in this fashion, so it dampers things a bit because now I have to use git log --follow on every single file I look up the history for.

Is there another way, or something that I am doing wrong, so that I can preserve the history under the right subdirectory? If it helps, the folder structure I want in my new repo is actually the same as the one in my old repo (well, at least before the git subtree command).

To be explicit, here is what I am starting with:

\old-repo
   \sub\dir\1
   \sub\dir\2
   \sub\dir\3

Here is where I am now:

\new-repo (subdir1 history viewable from here)
   \sub\dir\1 (subdir1 history is NOT viewable, besides the most recent git mv)

Here is what I actually want:

\new-repo
   \sub\dir\1 (subdir1 history viewable from here)
   \sub\dir\2 (subdir2 history viewable from here)
   \sub\dir\3 (subdir3 history viewable from here)
user3338893
  • 917
  • 3
  • 10
  • 17
  • Does this answer your question? [git move directory to another repository while keeping the history](https://stackoverflow.com/questions/41811986/git-move-directory-to-another-repository-while-keeping-the-history) – Hugh Perkins Nov 29 '21 at 15:03

0 Answers0