{"thread":{"id":"16517","subject":"Removing part of the history","startedAt":"2008-11-28T21:23:28Z","lastAt":"2008-11-28T22:38:22Z","messageCount":3,"participants":["Samuel Lucas Vaz de Mello","Miklos Vajna","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"96695","messageId":"49306150.6010701@datacom.ind.br","threadId":"16517","inReplyTo":null,"subject":"Removing part of the history","fromName":"Samuel Lucas Vaz de Mello","fromEmail":"samuellucas@datacom.ind.br","sentAt":"2008-11-28T21:23:28Z","receivedAt":"2008-11-28T21:23:28Z","isPatch":false,"sender":{"key":"samuellucas@datacom.ind.br","avatar":null},"body":"Hi All,\n\nI have a repository with code imported from CVS.\n\nI first imported from CVS using git 1.5.6 and we started to develop in git branches.\nI run cvsimport periodically and merged the changes from CVS (legacy developers) to our git branches.\nAfter some time, I realized that the import was broken, upgraded to git 1.6 and reimported the data.\nNow the imported data seems to be correct and I finished with a history tree like this:\n\n(our branch1)             X--Y--Z\nmerges>                  /    \\\n(our branch2)       J--K--L--M--N--O--P\nmerges>             /     /     /\n(cvs old) ...A--B--C--D--E     /\nmerges>                       /\n(cvs new) ...A'-B'-C'-D'-E'-F'\n\n\nThere is any way to get rid of the (broken) cvs-old tree?\n\nI've tried to rebase, but the commits from A' and A are different, it tries to reapply all history in CVS.\n\nI've tried to checkout a point before our changes start (B') and then, using a script, cherry-pick all commits up to HEAD that are not in cvs-old branch. This approach didn't handled well merges between our branches (K-L-M and X-Y).\n\nThe history from the beginning up to the point where our changes started (...A--B) is quite large, so it would be nice for us to get rid of it. \n\nAny suggestion on how to handle this?\n\nThank you,\n\n - Samuel\n"},{"id":"96696","messageId":"20081128213454.GE19355@genesis.frugalware.org","threadId":"16517","inReplyTo":"49306150.6010701@datacom.ind.br","subject":"Re: Removing part of the history","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-11-28T21:34:54Z","receivedAt":"2008-11-28T21:34:54Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Fri, Nov 28, 2008 at 07:23:28PM -0200, Samuel Lucas Vaz de Mello <samuellucas@datacom.ind.br> wrote:\n> There is any way to get rid of the (broken) cvs-old tree?\n> \n> I've tried to rebase, but the commits from A' and A are different, it\n> tries to reapply all history in CVS.\n\nHave you tried git rebase --onto?\n\n> I've tried to checkout a point before our changes start (B') and then,\n> using a script, cherry-pick all commits up to HEAD that are not in\n> cvs-old branch. This approach didn't handled well merges between our\n> branches (K-L-M and X-Y).\n\ngit rebase --preserve-merges is probably what you are searching for.\n"},{"id":"96700","messageId":"m3fxlbjx41.fsf@localhost.localdomain","threadId":"16517","inReplyTo":"49306150.6010701@datacom.ind.br","subject":"Re: Removing part of the history","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2008-11-28T22:38:22Z","receivedAt":"2008-11-28T22:38:22Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Samuel Lucas Vaz de Mello <samuellucas@datacom.ind.br> writes:\n\n> I have a repository with code imported from CVS.\n> \n> I first imported from CVS using git 1.5.6 and we started to develop\n> in git branches.  I run cvsimport periodically and merged the\n> changes from CVS (legacy developers) to our git branches.  After\n> some time, I realized that the import was broken, upgraded to git\n> 1.6 and reimported the data.  Now the imported data seems to be\n> correct and I finished with a history tree like this:\n> \n> (our branch1)             X--Y--Z\n> merges>                  /    \\\n> (our branch2)       J--K--L--M--N--O--P\n> merges>             /     /     /\n> (cvs old) ...A--B--C--D--E     /\n> merges>                       /\n> (cvs new) ...A'-B'-C'-D'-E'-F'\n> \n> \n> There is any way to get rid of the (broken) cvs-old tree?\n> \n> I've tried to rebase, but the commits from A' and A are different,\n> it tries to reapply all history in CVS.\n> \n> I've tried to checkout a point before our changes start (B') and\n> then, using a script, cherry-pick all commits up to HEAD that are\n> not in cvs-old branch. This approach didn't handled well merges\n> between our branches (K-L-M and X-Y).\n> \n> The history from the beginning up to the point where our changes\n> started (...A--B) is quite large, so it would be nice for us to get\n> rid of it.\n> \n> Any suggestion on how to handle this?\n\nYou can use grafts (see \"Repository Layout\" documentation) to prune\n'cvs old' branches, by adding for each merge commit <c_i> with one\nside leading to 'cvs old' branch line to .git/info/grafts\n  <c_i> <c_i^1>\nwhere <c_i> is full hexadecimal object name.\n\nThen check in gitk or some other history viewer if the history now\nlooks like you wanted (looks sane).\n\nThen use \"git filter-branch --all\" to turn grafts into reality, check\nout correctness, then remove refs/original/* and do git-gc.\n\nHTH\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}