Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scare of My Life With GIT: I've got no branch!

Tags:

git

branch

I had checked out an old hash (commit) and was working on it, checking in merrily and ignoring warnings that I wasn't working in a branch. Then I switched to a branch and realized that I had no way to get back to my orphaned checkins (luckily I had the terminal window open still, so I checked it out and branched).

How can I get GIT to tell me the names of the commits that do NOT belong to a branch? Or just all the commits, if that's not possible...

like image 369
Dan Rosenstark Avatar asked Feb 01 '10 17:02

Dan Rosenstark


2 Answers

git reflog will show the log of the references created by recent activity you've done. For future reference, git checkout of a commit puts you on an detached head. If you want to base work on an old commit, you should create a branch off of that commit instead.

git checkout -b newbranch oldsha1

or

git branch newbranch oldsha1
git checkout newbranch
like image 76
jamessan Avatar answered Nov 07 '22 15:11

jamessan


See this question which has a great explanation of how to find stashes you've dropped. You can see dangling commits etc. the same way.

like image 37
John Stoneham Avatar answered Nov 07 '22 15:11

John Stoneham