[Lilug] Git question, resetting my HEAD to the "main" HEAD

Mark Drago markdrago at gmail.com
Thu Jun 24 09:07:05 PDT 2010


Justin,

I hope I'm following you right.  I think you're saying that at some
point your master branch and their master branch were the same, then
you committed to your master branch, then they committed things to
their master and you pulled those changes on top of your master.  That
will result in a merge commit being made on your master, and
everything after that will have differing git revisions since the
history is different.

I think the correct way of doing this is to either create your own
personal branch which you commit to and rebase that from master from
time to time, or commit to your own master but then always do a rebase
and never a merge.  Really, I guess rebase is your friend.  You could
probably also just keep a branch-per-logical-change.  They should be
able to pull from that without a problem.

Anyway, I think the easiest way to fix your current situation is to
rename your existing master branch to something else, create a new
local master branch from theirs, and then follow one of the
afore-mentioned procedures.

Something like this should create oldmaster from master, delete
master, and then recreate master from the upstream master.  I should
also point out that the name 'master' is not special in anyway, so
this isn't strictly necessary, but for cleanliness purposes you might
want to do this.
git checkout master
git checkout -b oldmaster
git branch -d master
git checkout remotes/origin/master
git checkout -b master

Then, create your own custom branch, and cherry pick the commit from
the oldmaster branch on to it.
git checkout -b one-line-fix-branch
git cherry-pick <sha1sum of one line fix commit in oldmaster>

I hope that helps.  I also hope that I followed your description correctly.

Mark.

On Thu, Jun 24, 2010 at 11:36, Justin Dearing <zippy1981 at gmail.com> 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"
> Their head: git://github.com/mongodb/mongo.git Which is referred to as 10gen
> in my .git/config
> My Head: a local copy of git at github.com:zippy1981/mongo.git
> So What I'd like to end up with is a tag/branch of master thats where I am
> now, and my new master to be an exact copy of 10gen's master. Then I would
> reapply my 1 line change and make a push request.
> Any help appreciated.
>
> Justin
> _______________________________________________
> Lilug mailing list
> Lilug at lilug.org
> http://lists.lilug.org/listinfo.cgi/lilug-lilug.org
>
>



More information about the Lilug mailing list