[Lilug] Git question, resetting my HEAD to the "main" HEAD
Chris Knadle
Chris.Knadle at coredump.us
Thu Jun 24 13:30:37 PDT 2010
On Thursday 24 June 2010 11:36:31 Justin Dearing wrote:
> Hey folks,
>
> Some specifics. I've been contributing to mongo, and a patch I submitted
> was rejected because it could not be cleanly applied. Since I've been
> doing a lot of pushing an pulling, I wanted to reset my "HEAD" to their
> "HEAD"
I'm assuming you effectively want to UNDO commits/merges that have occurred.
The way in which I've done this in the past, which effectively _deletes_
commits and merges in a particular branch beyond a chosen point is to do a
'git checkout' to the place you want to be the last commit (i.e. the HEAD) and
then do a 'git reset --hard'. *WARNING*: this ONLY works for commits that are
local and have NOT been propagated elsewhere.
'man git-reset' has some good information you will want to read before doing
this. Another way to do what I believe is the same thing in a single step is
via 'git reset <commit>' which is what the author used in the link below:
http://linux.yyz.us/git-howto.html#undo_commits
The above also makes the assumption that you have NOT made any local
commits/merges to the master branch prior to the resulting HEAD.
Another way of doing this that is probably better and cleaner is if you start
a brand new repository via 'git clone' of the online 'master', make a new
branch, and make your one-line change.
-- Chris
--
Chris Knadle
Chris.Knadle at coredump.us
More information about the Lilug
mailing list