git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Lost a week?

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Apr 15, 2010, 14:16 UTC
Message-ID
<vpqtyrc6bse.fsf@bauges.imag.fr>
In-Reply-To
<t2s62a3a9cb1004150657g5baabb42o512e0e103d1e9596@mail.gmail.com>
Daniel Grace <negativeview@gmail.com> writes:
Show 5 quoted lines
> 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/
Previous: Thomas RastNext: Daniel Grace
Message 4 of 5 in “Lost a week?”
  1. Daniel GraceApr 15, 2010
  2. Michael J GruberApr 15, 2010
  3. Thomas RastApr 15, 2010
  4. Matthieu MoyApr 15, 2010
  5. Daniel GraceApr 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.