tags:

views:

67

answers:

1

Background

I'm working with just one branch - master.

        3---------2---------
                            |
6-------5---------4---------1----------

I made commits 1-3, then realised I wanted to work from commit 1 for the next section of work. I checked out commit 1, then made commits 4-6. Ooops. Commit 3 contains some important information I need.

The Problem

When I do a git log or view All Branches in GitX, all I see is this:

6-------5---------4---------1----------

How can I merge bits of commits 3 back to commit 6? (Is this called HEAD?)

Have I lost commits 2 and 3?

I know it was my fault for not making a new branch, but does that mean those commits are lost?

I'm still a Git newbie (despite using it for about 6 months) and still find it really confusing, so please be gentle!

+7  A: 

You have not lost the commits. They are available in the reflog.

Run git reflog and find the commits.

If you want the result to look like 6-5-4-3-2-1, checkout 6 and rebase it on 3.

Alex Brasetvik
Phew. Excellent! Thanks for the 7 minute turnaround! Awesome stuff.
John Gallagher