Re: How to recover a lost commit...
- From
- Patrick Doyle <wpdster@gmail.com>
- Date
- Nov 11, 2010, 18:19 UTC
- Message-ID
- <AANLkTik_zW1ih=wF-dWTjsFhToNy1fOxy0XJXT1i1RTo@mail.gmail.com>
- 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