Re: How to recover a lost commit...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 11, 2010 at 12:58 PM, Jonathan Nieder <jrnieder@xxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]