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

Re: How to recover a lost commit...

From
PDPatrick Doyle <wpdster@gmail.com>
Date
Nov 11, 2010, 17:34 UTC
Message-ID
<AANLkTikqBXjAf44O0QERH39rK+7nNA8uD2CwtPKJTTyV@mail.gmail.com>
In-Reply-To
<201011111649.oABGnjca019731@no.baka.org>
On Thu, Nov 11, 2010 at 11:49 AM, Seth Robertson <in-gitvger@baka.org> wrote:
Show 9 quoted lines
>                                        -Seth Robertson
>
> HEAD@{27} was your original problem.  You made the commit on @{32}
> then for some reason did (probably) a `git reset HEAD^` That was the
> source of all of your problems.  You should only use `git reset` if
> you have not pushed and if you are very sure you want to get rid of a
> commit or changes.  It is a powerful command and with great power
> comes great responsibility.
>

Hello Seth, Thank you for your reply and cogent explanation. Yes, in fact, I did do a "git reset HEAD^". Somewhere along the way, I decided that was a way to make my working copy look like it did prior to a commit.

I thought that git reset only affected HEAD. I didn't realize that it also affected the branch pointer.

Your "great power, great responsibility" comment will make me treat "git reset" with a lot more fear and respect.

It is confusing though, because I frequently see advice (such as that offered by Jonathan Nieder (and very much appreciated, by the way) to do things like:

$ git merge --no-commit $ git reset

Why is that "git reset" benign, when the "git reset HEAD^" wasn't benign before?
--wpd
Previous: Seth RobertsonNext: Jonathan Nieder
Message 3 of 8 in “How to recover a lost commit...”
  1. Patrick DoyleNov 11, 2010
  2. Seth RobertsonNov 11, 2010
  3. Patrick DoyleNov 11, 2010
  4. Jonathan NiederNov 11, 2010
  5. Patrick DoyleNov 11, 2010
  6. Junio C HamanoNov 11, 2010
  7. Jonathan NiederNov 11, 2010
  8. Patrick DoyleNov 11, 2010

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.