git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Howto update a 'dirty' entry in the cache from the object database

From
Junio C Hamano <junkio@cox.net>
Date
May 4, 2005, 17:37 UTC
Message-ID
<7vll6uopsr.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.58.0505041014510.2328@ppc970.osdl.org>
>>>>> "LT" == Linus Torvalds <torvalds@osdl.org> writes:
LT> On Wed, 4 May 2005, Thomas Glanzmann wrote:
Show 5 quoted lines
>> 
>> I edited a bunch of files and notice that I want to revert back one of
>> the files to the original one (the one that comes with HEAD). But I
>> already updated the cache. Is there a way to 'patch' the cache with the
>> original file.
LT> Absolutely.
LT> You can do it several ways. The easiest one is

LT> git-read-tree -m HEAD LT> git-checkout-cache -f filename

LT> but this means that you revert your entire index file to the old HEAD LT> information, so you'll need to do git-update-cache on the files that you LT> changed.

I think the easiest one that does not lose the cache for other files is:

    git-diff-cache -z HEAD |
    GIT_EXTERNAL_DIFF=git-apply-patch-script \
        git-diff-tree-helper -z -R filename

This means: find diff from HEAD to the cache, and apply the diff in the reverse, only to the filename.

Previous: Linus TorvaldsNext: Thomas Glanzmann
Message 3 of 4 in “Howto update a 'dirty' entry in the cache from the object database”
  1. Thomas GlanzmannMay 4, 2005
  2. Linus TorvaldsMay 4, 2005
  3. Junio C HamanoMay 4, 2005
  4. Thomas GlanzmannMay 4, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.