From: Ilia Pozhilov Date: Mon, 13 Mar 2023 11:48:40 GMT Subject: Re: Track git blame through two unrelated histories Message-ID: In-Reply-To: Track git blame through two unrelated histories Inbox Ilia Pozhilov Thu, Mar 9, 1:05 PM (4 days ago) Hello! I have a weird use case. A repository at my company was migrated git -> non-git vcs -> git again. During transition to non-git vcs the history was lost, Junio C Hamano Thu, Mar 9, 8:35 PM (4 days ago) to me, git Ilia Pozhilov writes: > So let's say I add two remotes and fetch all the commits, but they > look like this: > > A->B-> .... . . . -> Z history1 > > 1 -> 2 -> ..... -> 0 history2 > > and file contents in commits Z and 1 are exactly the same, but the > commits themselves are completely unrelated for git. You mean you want to pretend that history "2 -> ... -> 0" was built on top of Z? Here I am assuming that time flows from left to right in the picture. If so, you should be able to graft the histories together, perhaps? Totally untested but something like $ git replace --graft 1 Z based on my reading of "git help replace" should allow you to pretend that Z happened immediately before 1. Junio C Hamano (gitster@pobox.com), git@vger.kernel.org Plain text Ilia Pozhilov Fri, Mar 10, 6:32 PM (3 days ago) to Junio Thank you very much for this! It worked, I found the corresponding commits and did exactly as you suggested. Now blames just work! Now I will need to figure out if this is push'able to github, but even at this stage it's incredibly useful, I love blames! On Thu, Mar 9, 2023 at 8:35 PM Junio C Hamano wrote: > > Ilia Pozhilov writes: > > > So let's say I add two remotes and fetch all the commits, but they > > look like this: > > > > A->B-> .... . . . -> Z history1 > > > > 1 -> 2 -> ..... -> 0 history2 > > > > and file contents in commits Z and 1 are exactly the same, but the > > commits themselves are completely unrelated for git. > > You mean you want to pretend that history "2 -> ... -> 0" was built > on top of Z? Here I am assuming that time flows from left to right > in the picture. > > If so, you should be able to graft the histories together, perhaps? > > Totally untested but something like > > $ git replace --graft 1 Z > > based on my reading of "git help replace" should allow you to > pretend that Z happened immediately before 1. >