InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

Git tutorials

  • Github for beginners
  • Undo last commit
  • List git branches
  • Git checkout remote branch
  • Diff two branches
  • Show log of one user's commits
  • View diff for a given commit id
  • Setup password less git push for github
  • Git - Check if a hash is valid
  • Git - display specific length commit hash
  • Git - rename local branch
  • Git create branch
  • Git delete branch
  • Git detached head
  • Git display info of last commit (HEAD) in one line
  • Git display local HEAD location
  • Git log with file names
  • Git show details of a commit hash
 
  • Home
  • > Tutorials
  • > Git

Git detached head

on Mar 5, 2017

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

Note:

  1. git log shows only one entry (after detached head) as HEAD points to first commit.
  2. git log master shows two entries as master points to 2nd commit.

Suggested posts:

  1. Git – display specific length commit hash
  2. Git display info of last commit (HEAD) in one line
  3. How to recover svn lost password on Linux
  4. How to change twitter handle and its impact on traffic
  5. Git – Check if a hash is valid
  6. WordPress – write custom php log to separate file
  7. AngularJS format date using date filter
  8. Debug javascript using node-inspector, node-debug, nodemon and Chrome
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged Git, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress