1

I had this issue that the output of git branch used to be

* (no branch)
  master

Then I committed the changes and switched to the master branch, by running

git checkout master

Now I have to get back some files in *(no branch). How can I do that? The application is in production and has several changes, but I can't access...

jub0bs
  • 60,866
  • 25
  • 183
  • 186
Richard Feliciano
  • 115
  • 1
  • 1
  • 9
  • possible duplicate of [gitx How do I get my 'Detached HEAD' commits back into master](http://stackoverflow.com/questions/4845505/gitx-how-do-i-get-my-detached-head-commits-back-into-master) – Sascha Wolf Jan 05 '15 at 14:59
  • 2
    you can use git reflog to see when you switched the branch – clash Jan 05 '15 at 15:00

1 Answers1

0

Run git reflog to see where your HEAD has been before. Then it's best to use

git checkout -b some_new_branch_name commit_hash_from_reflog

to create a branch from that "lost" commit. You can then normally work with that branch and e.g. merge it.

knittl
  • 246,190
  • 53
  • 318
  • 364