Re: Restore a single file in the index back to HEAD

2 messages, 2 authors, 2016-08-11 · open the first message on its own page

Re: Restore a single file in the index back to HEAD

From: Junio C Hamano <hidden>
Date: 2016-08-11 19:52:07

"Nguyen Thai Ngoc Duy" [off-list ref] writes:
On 10/27/06, Junio C Hamano [off-list ref] wrote:
quoted
On the other hand, I designed --index-info to be compatible with
ls-tree output (it is not an accident, it was designed).  In

        git ls-tree HEAD frotz | git update-index --index-info

"frotz" part does not have to be the exact path but can be a
directory name.  It means "revert everything in this directory".

This is quite heavy-handed and you would probably want to run
update-index --refresh afterwards.
I would prefer "git update-index --reset frotz" or "git checkout
--index HEAD frotz". git ls-tree|git update-index is too cryptic for
me and too long for my fingers.
Then perhaps you can use "git checkout HEAD frotz", which is the
simplest?

Re: Restore a single file in the index back to HEAD

From: Andy Parkins <hidden>
Date: 2016-08-11 19:38:35

quoted
I would prefer "git update-index --reset frotz" or "git checkout
--index HEAD frotz". git ls-tree|git update-index is too cryptic for
me and too long for my fingers.
Then perhaps you can use "git checkout HEAD frotz", which is the
simplest?
Doesn't that update the working directory as well as the index?  My original 
question was addressed perfectly with the point at the "--index-info" switch. 
However, before I asked here I was looking at the man page for update-index 
looking for something like

  git-update-index --reset $FILE

I suppose, if it were being implemented it should be

  git-update-index --reset $COMMIT $FILE

Incidentally, this wouldn't be exactly the same as
  
  git-ls-tree $COMMIT $FILE | git-update-index --index-info

because the git-ls-tree version needs to be run from the root of the working 
directory (this bit me when I first ran it) while the 
(imaginary) "git-update-index --reset" would not.


Andy

-- 
Dr Andy Parkins, M Eng (hons), MIEE
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help