Question

So, I have two git repositories. One has history from (say) 2009-2012, and the other has 2012-now (including some duplicate commits between them). For one reason or another, we can't merge these together on the remote side. However, they both contain mostly the same files and such. One problem is when browsing code differences, I'll need to do a blame and need to see the full history of the file, from 2009-now, not just one or the other.

My best go at this has been pulling in the older repo as a second remote. In this way, I can at least see the commits between both of them for the single file.

How could I get blame to work across these two repositories, without modifying the remote repo and while keeping it easy to modify things and commit/push from my repo?

Was it helpful?

Solution

You can do this with graft points. From the new repo:

git remote add old /path/to/old-repo
git pull

Now, to do the graft and make it so that there is one single tree of commits, edit .gits/info/grafts

00c6d1bc0d3e4cd4bceef5966aa6478ae2c96a5a a936b291fd3cedb9a964a6d05b3c330ee310fe

You will have to change the hashes. The first hash is the initial commit of the new repo. The second hash is the last commit of the old repo.

See also: https://git.wiki.kernel.org/index.php/GraftPoint

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top