{"thread":{"id":"474","subject":"Howto update a 'dirty' entry in the cache from the object database","startedAt":"2005-05-04T14:23:51Z","lastAt":"2005-05-04T19:20:02Z","messageCount":4,"participants":["Thomas Glanzmann","Linus Torvalds","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"2570","messageId":"20050504142351.GL18380@cip.informatik.uni-erlangen.de","threadId":"474","inReplyTo":null,"subject":"Howto update a 'dirty' entry in the cache from the object database","fromName":"Thomas Glanzmann","fromEmail":"sithglan@stud.uni-erlangen.de","sentAt":"2005-05-04T14:23:51Z","receivedAt":"2005-05-04T14:23:51Z","isPatch":false,"sender":{"key":"sithglan@stud.uni-erlangen.de","avatar":null},"body":"Hello,\nI edited a bunch of files and notice that I want to revert back one of\nthe files to the original one (the one that comes with HEAD). But I\nalready updated the cache. Is there a way to 'patch' the cache with the\noriginal file. Or do I need todo a read-tree into a temporary index\nfile. Check out the one file from this alternate index file and use\nupdate-cache to update my original index file?\n\n\tThomas [ who want's a \"git revert\" ]\n"},{"id":"2581","messageId":"Pine.LNX.4.58.0505041014510.2328@ppc970.osdl.org","threadId":"474","inReplyTo":"20050504142351.GL18380@cip.informatik.uni-erlangen.de","subject":"Re: Howto update a 'dirty' entry in the cache from the object database","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-05-04T17:23:01Z","receivedAt":"2005-05-04T17:23:01Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 4 May 2005, Thomas Glanzmann wrote:\n>\n> I edited a bunch of files and notice that I want to revert back one of\n> the files to the original one (the one that comes with HEAD). But I\n> already updated the cache. Is there a way to 'patch' the cache with the\n> original file.\n\nAbsolutely.\n\nYou can do it several ways. The easiest one is\n\n\tgit-read-tree -m HEAD\n\tgit-checkout-cache -f filename\n\nbut this means that you revert your entire index file to the old HEAD \ninformation, so you'll need to do git-update-cache on the files that you \nchanged.\n\nSo:\n\n> Or do I need todo a read-tree into a temporary index\n> file. Check out the one file from this alternate index file and use\n> update-cache to update my original index file?\n\nYes. If you want to touch just that one file, and you actually _want_ to\nsave all the other index information updates except for this one file. If\nso, you can do\n\n\t# read a new index file with the HEAD information\n\tGIT_INDEX_FILE=tmp-index git-read-tree HEAD\n\n\t# check out just the one file you want to have\n\tGIT_INDEX_FILE=tmp-index git-checkout-cache -f filename\n\n\t# remove the now useless temporary index\n\trm tmp-index\n\n\t# update your _real_ index file with the file information\n\tgit-update-cache filename\n\nand you're done - you've now updated only that _one_ file in your working \narea, and you've re-set the index file for that entry.\n\nAnd yes, scripting it so that you don't make stupid mistakes is probably a\ngood idea. For exmple, if you misspell GIT_INDEX_FILE (like I did when I\nwrite that at first), you'd have reverted your real index file after all.\n\nIn other words, the git core certainly is very flexible and can easily do \nwhat you want, but it's also certainly very very easy to screw up with.\n\n\t\tLinus\n"},{"id":"2582","messageId":"7vll6uopsr.fsf@assigned-by-dhcp.cox.net","threadId":"474","inReplyTo":"Pine.LNX.4.58.0505041014510.2328@ppc970.osdl.org","subject":"Re: Howto update a 'dirty' entry in the cache from the object database","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-04T17:37:40Z","receivedAt":"2005-05-04T17:37:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":">>>>> \"LT\" == Linus Torvalds <torvalds@osdl.org> writes:\n\nLT> On Wed, 4 May 2005, Thomas Glanzmann wrote:\n>> \n>> I edited a bunch of files and notice that I want to revert back one of\n>> the files to the original one (the one that comes with HEAD). But I\n>> already updated the cache. Is there a way to 'patch' the cache with the\n>> original file.\n\nLT> Absolutely.\n\nLT> You can do it several ways. The easiest one is\n\nLT> \tgit-read-tree -m HEAD\nLT> \tgit-checkout-cache -f filename\n\nLT> but this means that you revert your entire index file to the old HEAD \nLT> information, so you'll need to do git-update-cache on the files that you \nLT> changed.\n\nI think the easiest one that does not lose the cache for other\nfiles is:\n\n    git-diff-cache -z HEAD |\n    GIT_EXTERNAL_DIFF=git-apply-patch-script \\\n        git-diff-tree-helper -z -R filename\n\nThis means: find diff from HEAD to the cache, and apply the diff\nin the reverse, only to the filename.\n\n"},{"id":"2588","messageId":"20050504192002.GH20994@cip.informatik.uni-erlangen.de","threadId":"474","inReplyTo":"Pine.LNX.4.58.0505041014510.2328@ppc970.osdl.org","subject":"Re: Howto update a 'dirty' entry in the cache from the object database","fromName":"Thomas Glanzmann","fromEmail":"sithglan@stud.uni-erlangen.de","sentAt":"2005-05-04T19:20:02Z","receivedAt":"2005-05-04T19:20:02Z","isPatch":false,"sender":{"key":"sithglan@stud.uni-erlangen.de","avatar":null},"body":"Hello,\n\n> \t# read a new index file with the HEAD information\n> \tGIT_INDEX_FILE=tmp-index git-read-tree HEAD\n\n> \t# check out just the one file you want to have\n> \tGIT_INDEX_FILE=tmp-index git-checkout-cache -f filename\n\n> \t# remove the now useless temporary index\n> \trm tmp-index\n\n> \t# update your _real_ index file with the file information\n> \tgit-update-cache filename\n\nthanks. That is exactly what I was looking for.\n\n\tThomas\n"}]}