Create a detached head situation
$ git branch * master $ git log --oneline 55fff69 v3 1fd2aa6 file1 $ git checkout 1fd2aa6 Note: checking out '1fd2aa6'. 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 1fd2aa6... file1 $ git log --oneline 1fd2aa6 file1 $ git log --oneline master 55fff69 v3 1fd2aa6 file1
- git log shows only one entry (after detached head) as HEAD points to first commit.
- git log master shows two entries as master points to 2nd commit.