{"thread":{"id":"3764","subject":"Moving a file back to an earlier revision.","startedAt":"2006-03-31T21:13:13Z","lastAt":"2006-04-03T08:29:08Z","messageCount":8,"participants":["David Ho","Linus Torvalds","Junio C Hamano","Petr Baudis","Karl Hasselström"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"18184","messageId":"4dd15d180603311313t7781f2ebk616276e9134f6472@mail.gmail.com","threadId":"3764","inReplyTo":null,"subject":"Moving a file back to an earlier revision.","fromName":"David Ho","fromEmail":"davidkwho@gmail.com","sentAt":"2006-03-31T21:13:13Z","receivedAt":"2006-03-31T21:13:13Z","isPatch":false,"sender":{"key":"davidkwho@gmail.com","avatar":"https://gravatar.com/avatar/1596ca9708bdd00a5c237f15af1011d65b6ef49a3bd9e9152e0bf09e7577fb5a?d=mp&s=160"},"body":"Hi,\n\nAnother user question.  Other may actually have similar needs.\n\nI am working on a board port on a separate branch.  The branch has\naccumulated several revision of changes to a driver I worked on.  Now,\nsomeone has come along with a better fix so I want to help test his\npatch.  To do that I have to revert my changes to that driver (several\nrevisions back) before I can apply his patch.\n\nWhat would be a convenient way to do that with git?\n\nTIA, David\n"},{"id":"18185","messageId":"Pine.LNX.4.64.0603311324040.27203@g5.osdl.org","threadId":"3764","inReplyTo":"4dd15d180603311313t7781f2ebk616276e9134f6472@mail.gmail.com","subject":"Re: Moving a file back to an earlier revision.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2006-03-31T21:26:19Z","receivedAt":"2006-03-31T21:26:19Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Fri, 31 Mar 2006, David Ho wrote:\n> \n> I am working on a board port on a separate branch.  The branch has\n> accumulated several revision of changes to a driver I worked on.  Now,\n> someone has come along with a better fix so I want to help test his\n> patch.  To do that I have to revert my changes to that driver (several\n> revisions back) before I can apply his patch.\n> \n> What would be a convenient way to do that with git?\n\nDon't revert.\n\nJust pick the point you want to start testing his patch at (with gitk, for \nexample, just cut-and-paste the sha1), and do\n\n\tgit checkout -b test-better-fix <sha1>\n\nwhich creates a new branch (\"test-better-fix\") that starts at that point, \nand checks it out. \n\nThen, just apply the patch, and off you go. You now have _both_ his patch \nand your own series in separate branches, so you can cherry-pick and do \nother things (like do a \"diff\" between branches - which can sometimes be \nuseful too to verify that the two branches end up fixing all the same \nproblems).\n\n\t\tLinus\n"},{"id":"18186","messageId":"4dd15d180603311332p60fa1867nc303bd92d515b4e0@mail.gmail.com","threadId":"3764","inReplyTo":"4dd15d180603311313t7781f2ebk616276e9134f6472@mail.gmail.com","subject":"Re: Moving a file back to an earlier revision.","fromName":"David Ho","fromEmail":"davidkwho@gmail.com","sentAt":"2006-03-31T21:32:16Z","receivedAt":"2006-03-31T21:32:16Z","isPatch":false,"sender":{"key":"davidkwho@gmail.com","avatar":"https://gravatar.com/avatar/1596ca9708bdd00a5c237f15af1011d65b6ef49a3bd9e9152e0bf09e7577fb5a?d=mp&s=160"},"body":"Sorry I might already have found it.\n\nFile revisions\n\n+----+----+\n1    2    3\n\ngit diff commit(3)..commit(1) filename | git-apply\n\nDavid\n\nOn 3/31/06, David Ho <davidkwho@gmail.com> wrote:\n> Hi,\n>\n> Another user question.  Other may actually have similar needs.\n>\n> I am working on a board port on a separate branch.  The branch has\n> accumulated several revision of changes to a driver I worked on.  Now,\n> someone has come along with a better fix so I want to help test his\n> patch.  To do that I have to revert my changes to that driver (several\n> revisions back) before I can apply his patch.\n>\n> What would be a convenient way to do that with git?\n>\n> TIA, David\n>\n"},{"id":"18187","messageId":"7vacb6thc7.fsf@assigned-by-dhcp.cox.net","threadId":"3764","inReplyTo":"4dd15d180603311332p60fa1867nc303bd92d515b4e0@mail.gmail.com","subject":"Re: Moving a file back to an earlier revision.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-03-31T21:49:44Z","receivedAt":"2006-03-31T21:49:44Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"David Ho\" <davidkwho@gmail.com> writes:\n\n>> I am working on a board port on a separate branch.  The branch has\n>> accumulated several revision of changes to a driver I worked on.  Now,\n>> someone has come along with a better fix so I want to help test his\n>> patch.  To do that I have to revert my changes to that driver (several\n>> revisions back) before I can apply his patch.\n>>\n>> What would be a convenient way to do that with git?\n>\n> Sorry I might already have found it.\n>\n> File revisions\n>\n> +----+----+\n> 1    2    3\n>\n> git diff commit(3)..commit(1) filename | git-apply\n\n[please do not top-post].\n\nThat lets you go back to the state before 1, so what you are\ndoing is to start from here:\n\n\t---0---1---2---3\n\nand\n\n\t---0---1---2---3---*\n\nwhere * has the same tree as 0, and then on top of that you\napply his patch:\n\n\t---0---1---2---3---X\n\nBut what if you find a room for further improvements in his\npatch?  You could commit X (which is revert of 321 *and* his\npatch) and then build on top of it, like this:\n\n\t---0---1---2---3---X---Y\n\nand feed him \"diff X..Y\" back.\n\nHowever.\n\nWhat Linus said is more natural in git.  Starting from the same\npicture, you do this:\n\n             X (side branch to test his patch on)\n            /\n\t---0---1---2---3 (your original branch)\n\nYou apply his patch to a new branch.  You could even make\nfurther improvements like this:\n\n             X---Y\n            /\n\t---0---1---2---3\n\nAnd if you decide Y is better than your version 3 after all, you\ncan switch to his branch and then pick up anything important\nfrom your development track between 0..3 on top of Y by\ncherry-picking, and you can even later discard your original\ndevelopment track.  On the other hand, if you end up deciding 3\nis better than Y after all, you can just discard the whole side\nbranch.\n\nRemember, a branch in git is very cheap, and is a powerful way\nto keep track of things while you decide which alternate\nuniverse to take.  And even after you decide, you could always\nlook at and even build on the other universe.\n"},{"id":"18188","messageId":"4dd15d180603311403o1f78ee56j707346e887463168@mail.gmail.com","threadId":"3764","inReplyTo":"Pine.LNX.4.64.0603311324040.27203@g5.osdl.org","subject":"Re: Moving a file back to an earlier revision.","fromName":"David Ho","fromEmail":"davidkwho@gmail.com","sentAt":"2006-03-31T22:03:45Z","receivedAt":"2006-03-31T22:03:45Z","isPatch":false,"sender":{"key":"davidkwho@gmail.com","avatar":"https://gravatar.com/avatar/1596ca9708bdd00a5c237f15af1011d65b6ef49a3bd9e9152e0bf09e7577fb5a?d=mp&s=160"},"body":"On 3/31/06, Linus Torvalds <torvalds@osdl.org> wrote:\n> Don't revert.\n>\n> Just pick the point you want to start testing his patch at (with gitk, for\n> example, just cut-and-paste the sha1), and do\n>\n>         git checkout -b test-better-fix <sha1>\n>\n> which creates a new branch (\"test-better-fix\") that starts at that point,\n> and checks it out.\n\nI forget to mention I have also in my branch changes necessary to run\non my board.  So what I did was\n\ngit-branch test-better-fix my-branch\ngit-checkout test-better-fix\ngit-diff commit(my-fixes)..commit(original) filename | git-apply\ngit-commit\n\n>\n> Then, just apply the patch, and off you go. You now have _both_ his patch\n> and your own series in separate branches, so you can cherry-pick and do\n> other things (like do a \"diff\" between branches - which can sometimes be\n> useful too to verify that the two branches end up fixing all the same\n> problems).\n>\n\nYes, good point.\n\nThanks, David\n"},{"id":"18189","messageId":"4dd15d180603311421w7b48cfa4y80d3f9d565d4276f@mail.gmail.com","threadId":"3764","inReplyTo":"7vacb6thc7.fsf@assigned-by-dhcp.cox.net","subject":"Re: Moving a file back to an earlier revision.","fromName":"David Ho","fromEmail":"davidkwho@gmail.com","sentAt":"2006-03-31T22:21:48Z","receivedAt":"2006-03-31T22:21:48Z","isPatch":false,"sender":{"key":"davidkwho@gmail.com","avatar":"https://gravatar.com/avatar/1596ca9708bdd00a5c237f15af1011d65b6ef49a3bd9e9152e0bf09e7577fb5a?d=mp&s=160"},"body":"> Remember, a branch in git is very cheap, and is a powerful way\n> to keep track of things while you decide which alternate\n> universe to take.  And even after you decide, you could always\n> look at and even build on the other universe.\n\nI feel embarrassed to say this but in my branch there are commits to\nthe driver and other commits for the board so it looks more like\n\n---0---D1---B1---B2---D2---B3---B4---\n\nD* - driver changes\nB* - board changes\n\nSo to go back to the 0 state I lose my board changes.  But I hope what\nI did (in my reply to Linus) is very close to your idea of having\nseparate branches.\n\nDavid\n"},{"id":"18201","messageId":"20060401230144.GL27689@pasky.or.cz","threadId":"3764","inReplyTo":"4dd15d180603311332p60fa1867nc303bd92d515b4e0@mail.gmail.com","subject":"Re: Moving a file back to an earlier revision.","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-04-01T23:01:44Z","receivedAt":"2006-04-01T23:01:44Z","isPatch":false,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Mar 31, 2006 at 11:32:16PM CEST, I got a letter\nwhere David Ho <davidkwho@gmail.com> said that...\n> Sorry I might already have found it.\n> \n> File revisions\n> \n> +----+----+\n> 1    2    3\n> \n> git diff commit(3)..commit(1) filename | git-apply\n\nNote that it might be more convenient to just say \"restore the file to\nthe contents as of commit X\" - in pure Git this would involve dances\nwith git-ls-tree and git-cat-file, I'm not sure if the core Git\nporcelain has an interface for doing this easily.\n\nIn Cogito, you can just do:\n\n\tcg-restore -f -r commitid filename\n\n-- \n\t\t\t\tPetr \"Pasky on a dialup\" Baudis\nStuff: http://pasky.or.cz/\nRight now I am having amnesia and deja-vu at the same time.  I think\nI have forgotten this before.\n"},{"id":"18272","messageId":"20060403082908.GA4541@diana.vm.bytemark.co.uk","threadId":"3764","inReplyTo":"4dd15d180603311421w7b48cfa4y80d3f9d565d4276f@mail.gmail.com","subject":"Re: Moving a file back to an earlier revision.","fromName":"Karl Hasselström","fromEmail":"kha@treskal.com","sentAt":"2006-04-03T08:29:08Z","receivedAt":"2006-04-03T08:29:08Z","isPatch":false,"sender":{"key":"kha@treskal.com","avatar":"https://gravatar.com/avatar/f0120c734b5279b345075a28521e1ac66acb20c9913ffe9bf6ae97e53f7f3f13?d=mp&s=160"},"body":"On 2006-03-31 17:21:48 -0500, David Ho wrote:\n[quoting junkio]\n\n> > Remember, a branch in git is very cheap, and is a powerful way to\n> > keep track of things while you decide which alternate universe to\n> > take. And even after you decide, you could always look at and even\n> > build on the other universe.\n>\n> I feel embarrassed to say this but in my branch there are commits to\n> the driver and other commits for the board so it looks more like\n>\n> ---0---D1---B1---B2---D2---B3---B4---\n>\n> D* - driver changes\n> B* - board changes\n>\n> So to go back to the 0 state I lose my board changes. But I hope\n> what I did (in my reply to Linus) is very close to your idea of\n> having separate branches.\n\nYou could use either stgit or the cherry-picking stuff in git to\ncreate a new branch with these commits, but reordered any way you\nlike. (Or, given what you want to use it for, maybe two separate topic\nbranches -- one for board changes and one for driver changes -- that\ncan be merged to produce the end result.)\n\n-- \nKarl Hasselström, kha@treskal.com\n      www.treskal.com/kalle\n"}]}