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

[PATCH] Added description for reversing git-update-index using --index-info

From
APAndy Parkins <andyparkins@gmail.com>
Date
Nov 2, 2006, 11:13 UTC
Message-ID
<200611021113.01812.andyparkins@gmail.com>

I wanted to restore a single file from HEAD back to the index; Shawn Pearce gave me the answer. git-ls-tree piped to git-update-index --index-info.

This patch adds that answer to the git-update-index documentation.
Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 Documentation/git-update-index.txt |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index 41bb7e1..5adf717 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -215,6 +215,24 @@ for that path.  After the above, we woul
 100755 8a1218a1024a212bb3db30becd860315f9f3ac52 2	frotz
 ------------
 
+One particular use of --index-info is to reverse the effect of
+"git-update-index frotz":
+
+------------
+git ls-tree HEAD frotz | git update-index --index-info
+------------
+
+This makes the index hold the file frotz from HEAD rather than from the
+working copy.  Similarly:
+
+------------
+git ls-tree -r HEAD | git update-index --index-info
+------------
+
+Will undo everything except "git add" from the index, as
+"git-ls-tree -r" lists everything in the last commit.
+
+
 
 Using "assume unchanged" bit
 ----------------------------
-- 
1.4.3.2
Next: Junio C Hamano
Message 1 of 3 in “Added description for reversing git-update-index using --index-info”
  1. Added description for reversing git-update-index using --index-infoAndy Parkins, Nov 2, 2006
  2. Junio C HamanoNov 3, 2006
  3. Andy ParkinsNov 3, 2006

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.