git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Doyle <wpdster@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Seth Robertson <in-gitvger@baka.org>, git <git@vger.kernel.org>
Subject: Re: How to recover a lost commit...
Date: Thu, 11 Nov 2010 13:19:09 -0500	[thread overview]
Message-ID: <AANLkTik_zW1ih=wF-dWTjsFhToNy1fOxy0XJXT1i1RTo@mail.gmail.com> (raw)
In-Reply-To: <20101111175836.GD16972@burratino>

On Thu, Nov 11, 2010 at 12:58 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Right.  In general, git operations that update HEAD also tend to take
> the current branch along with them.
Ahhhh.... that's the missing piece, errr, one of the missing pieces,
to my puzzled brain.

So

$ git reset HEAD

updates HEAD (and whatever branch we are currently on) to point to
HEAD.  Except for mucking with the index, that seems pretty benign.

$ git reset HEAD^

updates HEAD (and whatever branch we are currently on) to point to
HEAD^, thus backing everything up by 1 commit.  As you pointed out,
this is dangerous/not a good idea/ if I've already pushed my
repository someplace.

In my particular case, after doing the "git reset HEAD^" on my
svn_to_git_wip branch, I later tried to switch back to master ("git
checkout master").  Git warned me about files that were not up to date
and refused to merge (but I thought I was checking out, not merging).
Since I knew what I was doing (we all know how sadly lacking in truth
that statement is now, don't we), I "git reset --hard" those files
(thus discarding my changes) and proceeded to check out master.

Light dawns on marble head.

Thanks again.

--wpd

  reply	other threads:[~2010-11-11 18:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-11 16:29 How to recover a lost commit Patrick Doyle
2010-11-11 16:49 ` Seth Robertson
2010-11-11 17:34   ` Patrick Doyle
2010-11-11 17:58     ` Jonathan Nieder
2010-11-11 18:19       ` Patrick Doyle [this message]
2010-11-11 17:58     ` Junio C Hamano
2010-11-11 16:50 ` Jonathan Nieder
2010-11-11 17:39   ` Patrick Doyle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTik_zW1ih=wF-dWTjsFhToNy1fOxy0XJXT1i1RTo@mail.gmail.com' \
    --to=wpdster@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=in-gitvger@baka.org \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).