Re: Lost a week?

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

 



Daniel Grace <negativeview@xxxxxxxxx> writes:

> github shows the same. I KNOW that there were commits (representing a
> good bit of work) in that time. I'm sure that it's *somewhere* but I'm
> at a complete loss as to where it is. gitk shows no side branches (nor
> does git branch). I don't use branches really, as much as I know that
> I should.

I guess you've been on a detached HEAD for some time. Recent version
of Git warn you this way when you enter in this state:

,----
| Note: checking out 'HEAD^'.
| 
| You are in 'detached HEAD' state. You can look around, make experimental
| changes and commit them, and you can discard any commits you make in this
| state without impacting any branches by performing another checkout.
| 
| If you want to create a new branch to retain commits you create, you may
| do so (now or later) by using -b with the checkout command again. Example:
| 
|   git checkout -b new_branch_name
| 
| HEAD is now at a8e7ba9... foo
`----

Now, your changes are probably not lost forever: they're not reachable
from a branch, but still there (but don't play with "git gc" until
you're sure you've recovered all of it...). "git reflog" should give
you the sha1 of the commit you're looking for (if you didn't really
mess up everything, you really look for just one commit, which is the
tip of the sequence of commits you did while on a detached HEAD, that
is, the one just before you did "git checkout master".

Then, do

git branch tmp <the-sha1-you-found>
(possibly run "gitk --all" to understand, here)
git merge tmp

to create a branch named tmp containing your commits, and merge it
into your current branch. Naming the branch isn't strictly necessary,
but will help in case you do anything wrong trying to merge.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
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]