Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view history of git subtree?

I have two repos (let's call them oldrepo1 and oldrepo2). These two repos have 20k and 21k commits respectively in their current history. I'm merging them together in a new repo, each one under a subdir:

newrepo/oldrepo1

newrepo/oldrepo2

I've used these commands to populate the new repo

git subtree add --message="Migrate oldrepo1" --prefix=oldrepo1 <oldrepo1 url> master

git subtree add --message="Migrate oldrepo2" --prefix=oldrepo2 <oldrepo2 url> master

when I go into the root of newrepo, and run "git --no-pager log --graph --oneline" I get 41k commits, as expected, but if I drill down to any level underneath and run git log all I get is the "Migrate oldrepoX" commit:

For instance, I have a file that has had 60 changes in the original repo, but when I run git log on that same file in the new repo, all I get is:

commit <commitid>
  Author: Me <[email protected]>
  Date:   Fri Sep 18 23:17:28 2020 -0700

      Migrate oldrepo1

      git-subtree-dir: oldrepo1
      git-subtree-mainline: <somecommitid>
      git-subtree-split: <somecommitid>

I didn't squash any history when I migrated, so why can't I see the 60 commits to this file in the new repo?

like image 845
Rusty Morris Avatar asked Oct 19 '25 03:10

Rusty Morris


1 Answers

I opted for a different approach, using git-filter-repo to remap each repo into subfolders and merge those modified repos into the new repo, as described by x-yuri in this discussion:

How to import existing Git repository into another?

with the details further spelled out here:

https://gist.github.com/x-yuri/6161d90d1af8ebac6e560bcef548c1c3

like image 119
Rusty Morris Avatar answered Oct 22 '25 00:10

Rusty Morris