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

git-add + git-reset --hard = Arrrggh!

From
Shawn Pearce <spearce@spearce.org>
Date
May 17, 2006, 09:45 UTC
Message-ID
<20060517094526.GA8563@spearce.org>

After spending an hour writing and testing a new test case for GIT I do the foolish:

	$ git add t/t1400-update-ref.sh
	# Hmm, maybe I should amend this into the prior commit.
	$ git format-patch -o .. next
	$ git reset --hard
	$ git update-ref HEAD~1
	# Uhhohh...
	$ ls t/t1400-update-ref.sh

All I can say is I'm very happy that update-index does a lot more than just update the index. I was easily able to find the deleted test by finding the most recently modified object in my .git/objects directory and pulling it back out with git cat-file. :-)

Oh, and I totally agree with that discussion about GIT not clobbering files the user is working on which the user can't easily recover. I just wish recovery from the above stupidity didn't require going through .git/objects looking for the newest file. :-)

Yes, I know that git reset --hard was brutal and yes, I didn't really need to use git-update-ref when git-reset would have also done the job for me. Arrgh. Its early and I wasn't thinking.

-- 
Shawn.
Next: Linus Torvalds
Message 1 of 3 in “git-add + git-reset --hard = Arrrggh!”
  1. Shawn PearceMay 17, 2006
  2. Linus TorvaldsMay 17, 2006
  3. Shawn PearceMay 17, 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.