Monday, October 29, 2018

Lesson5: Detaching Head in git

  1. Detaching HEAD:

    Detaching HEAD just means attaching it to a commit instead of a branch. This is what it looks like beforehand:
    Start:
         git checkout C1  ->     

    • git checkout master
    • git commit
    • git checkout C2
     

    1.  Examples: 
     
    2.Purpose branch:
     
    Type command:
    • git checkout C4. 
    Note:
    Moving around in Git by specifying commit hashes can get a bit tedious. In the real world you won't have a nice commit tree visualization next to your terminal, so you'll have to use git log to see hashes.
    Furthermore, hashes are usually a lot longer in the real Git world as well. For instance, the hash of the commit that introduced the previous level is fed2da64c0efc5293610bdd892f82a58e8cbc5d8. Doesn't exactly roll off the tongue...
    The upside is that Git is smart about hashes. It only requires you to specify enough characters of the hash until it uniquely identifies the commit. So I can type fed2 instead of the long string above.

No comments:

Post a Comment