{"thread":{"id":"8640","subject":"how to move with history?","startedAt":"2007-06-18T19:16:07Z","lastAt":"2007-06-19T22:59:15Z","messageCount":9,"participants":["Oliver Kullmann","Alex Riesen","J. Bruce Fields","Frank Lichtenheld","Robin Rosenberg","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"45275","messageId":"20070618191607.GK3037@cs-wsok.swansea.ac.uk","threadId":"8640","inReplyTo":null,"subject":"how to move with history?","fromName":"Oliver Kullmann","fromEmail":"o.kullmann@swansea.ac.uk","sentAt":"2007-06-18T19:16:07Z","receivedAt":"2007-06-18T19:16:07Z","isPatch":false,"sender":{"key":"o.kullmann@swansea.ac.uk","avatar":null},"body":"Hello,\n\nI try to understand \"git mv\"; here is\nhow far I got:\n\n1. Suppose I have \"file\" (under git control).\n\n2. I issue \"git mv file new_file\".\n\n3. Then I have to commit the renaming.\nI can't find anything on how to do this\n(neither in the git-mv- nor in the\ngit-commit-documentation).\nSo a hack is to use \"git commit -a\".\nApparently this works.\n\n4. Now I have \"new_file\" in the repository, but\nwithout history (except of the renaming operation),\nand I have still \"file\" in this history, but\nI can no longer get access to the history of\n\"file\" via \"gitk file\" ?\n\n\nThis looks a bit strange to me (the renamed file has\nno history, the old file still lurking around, but not\neasily accessible).\n\nBut perhaps this is as it is (since other solutions might be\neven stranger under certain circumstances)?\n\nIs it then possible to complete the move, that is, to really\n\"move\" the history of \"file\" to the history of \"new_file\", so\nthat after that except of some moving-information there is\nno trace left of \"file\", while \"new_file\" has taken over the\nold history?\n\n(The motivation is as follows: I want to make the library I've \ndeveloped available as a clone, but I have the problem that\nthere are special files which I do not want to make available.\nSo I hope that in the future with \"git-submodule\" I can filter\nout the special files, creating a (sub-)repository\nwithout the special files which then can be freely cloned.\nNow the special files yet are spread around, and to solve this\nI want to introduce a special naming-pattern for the special\nfiles (so that it becomes easy to separate the special files from\nthe rest). But in order to do so I need the ability to fully\nmove the special files to their renamed versions, completely\nwith history (otherwise by browsing the history of the clone\nthe special files would be revealed).)\n\nI would be glad for any help!\n\nOliver\n"},{"id":"45277","messageId":"20070618194907.GA12445@steel.home","threadId":"8640","inReplyTo":"20070618191607.GK3037@cs-wsok.swansea.ac.uk","subject":"Re: how to move with history?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-18T19:49:07Z","receivedAt":"2007-06-18T19:49:07Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Oliver Kullmann, Mon, Jun 18, 2007 21:16:07 +0200:\n> 2. I issue \"git mv file new_file\".\n> \n> 3. Then I have to commit the renaming.  I can't find anything on how\n> to do this (neither in the git-mv- nor in the git-commit-documentation).\n\nJust git-commit. git-mv is only so you don't have to run git add on\nthe new file name and don't need to run \"git-commit -a\" afterwords.\n\n> So a hack is to use \"git commit -a\".  Apparently this works.\n\nEven a plain \"mv file new_file; git add new_file\" would have worked.\n\n> 4. Now I have \"new_file\" in the repository, but without history\n> (except of the renaming operation),\n\nIt does. Try \"git log file new_file\". After committing, that is\n\n> and I have still \"file\" in this history, but I can no longer get\n> access to the history of \"file\" via \"gitk file\" ?\n\nWell, you didn't commit the change yet.\n\n> This looks a bit strange to me (the renamed file has\n> no history, the old file still lurking around, but not\n> easily accessible).\n\nGit does not keep \"renaming history\". It does not have to, as it keeps\nhow your project looked at each commit (point in history).\n"},{"id":"45278","messageId":"20070618202918.GM3037@cs-wsok.swansea.ac.uk","threadId":"8640","inReplyTo":"20070618194907.GA12445@steel.home","subject":"Re: how to move with history?","fromName":"Oliver Kullmann","fromEmail":"o.kullmann@swansea.ac.uk","sentAt":"2007-06-18T20:29:18Z","receivedAt":"2007-06-18T20:29:18Z","isPatch":false,"sender":{"key":"o.kullmann@swansea.ac.uk","avatar":null},"body":"On Mon, Jun 18, 2007 at 09:49:07PM +0200, Alex Riesen wrote:\n> Oliver Kullmann, Mon, Jun 18, 2007 21:16:07 +0200:\n> > 2. I issue \"git mv file new_file\".\n> > \n> > 3. Then I have to commit the renaming.  I can't find anything on how\n> > to do this (neither in the git-mv- nor in the git-commit-documentation).\n> \n> Just git-commit. git-mv is only so you don't have to run git add on\n> the new file name and don't need to run \"git-commit -a\" afterwards.\n> \n> > So a hack is to use \"git commit -a\".  Apparently this works.\n> \n> Even a plain \"mv file new_file; git add new_file\" would have worked.\n> \n> > 4. Now I have \"new_file\" in the repository, but without history\n> > (except of the renaming operation),\n> \n> It does. Try \"git log file new_file\". After committing, that is\n> \n> > and I have still \"file\" in this history, but I can no longer get\n> > access to the history of \"file\" via \"gitk file\" ?\n> \n> Well, you didn't commit the change yet.\n> \n> > This looks a bit strange to me (the renamed file has\n> > no history, the old file still lurking around, but not\n> > easily accessible).\n> \n\n\nI think, there is a bit of a misunderstanding going on, but this doesn't matter,\nI believe now that I understand what \"git mv\" is doing (thanks!).\n \nSo that leaves then 2 open question:\n\n> Git does not keep \"renaming history\". It does not have to, as it keeps\n> how your project looked at each commit (point in history).\n\nFor my purposes, that is a bad thing, since I want to get rid off some parts\nof the history (specifically I want to eliminate some files from history),\nas explained in that last paragraph in my e-mail (with the motivation):\n\nIs this possible in git?\n\nAnd is it possible to add the history of some file to the history\nof another file (in the above application this would be the renamed\nfile) ?\n\nAltogether, I want to completely change history: It must look as\nif the old files never has been there (from the git-history that is),\nbut as it would have had always the new name.\n\nIf this is not possible with Git (this \"history surgery\"), then\nI hope that at least the future \"git-submodule\" will not have\nthe files in the history which have been filtered out?\n\nSo that in this way at least files can be hidden in (sub-)clones (but\nthey cannot be renamed) ?\n\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"45279","messageId":"20070618203116.GK2334@fieldses.org","threadId":"8640","inReplyTo":"20070618202918.GM3037@cs-wsok.swansea.ac.uk","subject":"Re: how to move with history?","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-06-18T20:31:16Z","receivedAt":"2007-06-18T20:31:16Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Mon, Jun 18, 2007 at 09:29:18PM +0100, Oliver Kullmann wrote:\n> On Mon, Jun 18, 2007 at 09:49:07PM +0200, Alex Riesen wrote:\n> > Git does not keep \"renaming history\". It does not have to, as it keeps\n> > how your project looked at each commit (point in history).\n> \n> For my purposes, that is a bad thing, since I want to get rid off some parts\n> of the history (specifically I want to eliminate some files from history),\n> as explained in that last paragraph in my e-mail (with the motivation):\n\nOh, so even if somebody checks out a previous version of the project,\nyou don't want them to see that file at the old name any more?\n\nThe git history is totally immutable, by design--the SHA1 name of a\ncommit is taken over the commit, the contents of the entire tree at that\npoint, and any commit(s) that precede this commit--hence it recursively\nsummarizes the entire history of the project.\n\nSo if you want to erase all memory of a path from the git history, then\nyou have to rebuild it all.  Which is possible--it'd just mean creating\na new project and writing a script to import every version into the new\nproject....\n\n--b.\n"},{"id":"45280","messageId":"20070618203623.GA19725@planck.djpig.de","threadId":"8640","inReplyTo":"20070618203116.GK2334@fieldses.org","subject":"Re: how to move with history?","fromName":"Frank Lichtenheld","fromEmail":"frank@lichtenheld.de","sentAt":"2007-06-18T20:36:23Z","receivedAt":"2007-06-18T20:36:23Z","isPatch":false,"sender":{"key":"frank@lichtenheld.de","avatar":"https://gravatar.com/avatar/b9f1d4b120e138f157c9e480d0818197c474628923786adb98f30017cdb99c3c?d=mp&s=160"},"body":"On Mon, Jun 18, 2007 at 04:31:16PM -0400, J. Bruce Fields wrote:\n> On Mon, Jun 18, 2007 at 09:29:18PM +0100, Oliver Kullmann wrote:\n> So if you want to erase all memory of a path from the git history, then\n> you have to rebuild it all.  Which is possible--it'd just mean creating\n> a new project and writing a script to import every version into the new\n> project....\n\nIsn't that what git-filter-branch is for?\n\nGruesse,\n-- \nFrank Lichtenheld <frank@lichtenheld.de>\nwww: http://www.djpig.de/\n"},{"id":"45281","messageId":"200706182243.27068.robin.rosenberg.lists@dewire.com","threadId":"8640","inReplyTo":"20070618202918.GM3037@cs-wsok.swansea.ac.uk","subject":"Re: how to move with history?","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2007-06-18T20:43:26Z","receivedAt":"2007-06-18T20:43:26Z","isPatch":false,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"måndag 18 juni 2007 skrev Oliver Kullmann:\n> > Git does not keep \"renaming history\". It does not have to, as it keeps\n> > how your project looked at each commit (point in history).\n> \n> For my purposes, that is a bad thing, since I want to get rid off some parts\n> of the history (specifically I want to eliminate some files from history),\n> as explained in that last paragraph in my e-mail (with the motivation):\n> \n> Is this possible in git?\n>\n> And is it possible to add the history of some file to the history\n> of another file (in the above application this would be the renamed\n> file) ?\n\nGit does not keep file histories at all. As a consequence it does not track renames\neither.\n\nThe history in Git is the history of the *whole* tree as a chunk, not a sum of file histories. \nIt takes snapshots of your project, that's all. Then there are tools to do magic on top of \nthat (e.g. git-blame).\n\nThere are tools to rewrite histories, but then you are violating of \nthe key principles of git, that history is immutable so git may not be nice to \nyou after history rewriting. Cogito has a powerful command.\n\n-- robin\n"},{"id":"45282","messageId":"20070618210743.GA16397@steel.home","threadId":"8640","inReplyTo":"20070618202918.GM3037@cs-wsok.swansea.ac.uk","subject":"Re: how to move with history?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-06-18T21:07:43Z","receivedAt":"2007-06-18T21:07:43Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Oliver Kullmann, Mon, Jun 18, 2007 22:29:18 +0200:\n> > Git does not keep \"renaming history\". It does not have to, as it keeps\n> > how your project looked at each commit (point in history).\n> \n> For my purposes, that is a bad thing, since I want to get rid off some parts\n> of the history (specifically I want to eliminate some files from history),\n> as explained in that last paragraph in my e-mail (with the motivation):\n> \n> Is this possible in git?\n\nYes. You wont be able to change the history after someone copied it\nfrom you (cloned or fetched), because it's \"his\" now, but you're free\nto do anything with your part (or whole) of the history. Happens all\nthe time. Look at git-cherry-pick, git-format-patch and git-am (and\nthe new git-filter-branch, but is more for automated mass-rewriting of\nbig histories).\n\n> And is it possible to add the history of some file to the history\n> of another file (in the above application this would be the renamed\n> file) ?\n\nYes, git-format-patch accept pathnames, and its output can be passed\nto git-am, which will apply the changes to this file only. git-am also\naccepts -pN, so you can move file up a bit. For more complex path\nmanipulations you'll have to modify the patches (or git-filter-branch\nagain).\n\n> Altogether, I want to completely change history: It must look as\n> if the old files never has been there (from the git-history that is),\n> but as it would have had always the new name.\n\nYep, no problem, just a bit of scripting. Just make sure no one has\nthat \"old\" history: it will be hell to merge with them.\n\n> If this is not possible with Git (this \"history surgery\"),\n\nno, it is not.\n\n> then I hope that at least the future \"git-submodule\" will not have\n> the files in the history which have been filtered out?\n\ndepends on how you write the history for that submodule\n\n> So that in this way at least files can be hidden in (sub-)clones (but\n> they cannot be renamed) ?\n\n?\n"},{"id":"45374","messageId":"20070619192834.GS3037@cs-wsok.swansea.ac.uk","threadId":"8640","inReplyTo":"20070618210743.GA16397@steel.home","subject":"Re: how to move with history?","fromName":"Oliver Kullmann","fromEmail":"o.kullmann@swansea.ac.uk","sentAt":"2007-06-19T19:28:34Z","receivedAt":"2007-06-19T19:28:34Z","isPatch":false,"sender":{"key":"o.kullmann@swansea.ac.uk","avatar":null},"body":"Thanks for all the replies!\n\nNow I see pretty clear; a quick summary\n(in case somebody else wants to learn from this):\n\n1.\n\n\"git mv file new_file\" seems to be (exactly?) equivalent to\n\nmv file new_file\ngit rm file\ngit add new_file\n\n(Perhaps this information could be added to the git-mv-documentation?\nI would have found it useful (since I had a different expectation).)\n\n2. To do something with the history, for example to rename \"file\"\nto \"new_file\" also in the whole history, a new repository (or\na new branch) has to be created. Three possibilities:\n \n (a) Using the basic git-functionality, re-creating a repository\n     by re-creating all commits (with appropriate changes) by \"hand\"\n     or \"script\".\n (b) More convenient, the upcoming \"git-filter-branch\" apparently\n     makes filtering out easier.\n (c) Or, apparently more powerful, with \"cg-admin-rewritehis\"\n     (part of the cogito-tool) we have quite a powerful tool\n     for creating a branch with a (re-created and modified)\n     history (the documentation explicitely mentions how to\n     remove a file from history --- that is, in the new branch).\n\nHope that's correct.\n\nThanks a lot to all!\n\nOliver\n"},{"id":"45391","messageId":"f59n44$7hg$1@sea.gmane.org","threadId":"8640","inReplyTo":"20070619192834.GS3037@cs-wsok.swansea.ac.uk","subject":"Re: how to move with history?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-06-19T22:59:15Z","receivedAt":"2007-06-19T22:59:15Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Oliver Kullmann wrote:\n\n>  (b) More convenient, the upcoming \"git-filter-branch\" apparently\n>      makes filtering out easier.\n>  (c) Or, apparently more powerful, with \"cg-admin-rewritehis\"\n>      (part of the cogito-tool) we have quite a powerful tool\n>      for creating a branch with a (re-created and modified)\n>      history (the documentation explicitely mentions how to\n>      remove a file from history --- that is, in the new branch).\n\ngit-filter-branch _is_ cg-admin-rewritehist (or at least should be).\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}