Scare of My Life With GIT: I've got no 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…

  • Why does git checking out origin/master leads to detached-HEAD
  • git branch naming best practices
  • Why am I able to create the same SVN branch twice?
  • git merge with --no-ff and --squash
  • git: How to get the latest commit on a specific file, regardless of branch?
  • What is the optimal range for number of live branches?
  • IntelliJ git fetch pruned remote references
  • how do I complete a git commit?
  • Source Tree and Github not seeing all of my files
  • Structuring related components in git
  • Very strange git behavior when merging old branch into develop
  • Found a swap file by the name “.git/.MERGE_MSG.swp”
  • 3 Solutions collect form web for “Scare of My Life With GIT: I've got no branch!”

    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.

    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


    git branch newbranch oldsha1
    git checkout newbranch

    You can fish them out of the reflog, which stores the commits which you’ve had checked out.

    git reflog will print out the most recent commits pointed to by HEAD, which is your working copy.

    You can also get a list of all objects in your tree which are unreachable from your current branches using git fsck.

    Git Baby is a git and github fan, let's start git clone.