Sunday, November 11, 2018

Lesson 5.1 Relative Refs (^)

1. Move  up commit :
  • Moving upwards one commit at a time with ^
  • Moving upwards a number of times with ~<num>.
We can say: 

So saying master^ is equivalent to "the first parent of master". 
master^^ is the grandparent (second-generation ancestor) of master
Example:
Command type: git checkout master^  













Other example:

Branch start:                        Branch goal:
                             

Answer:
  • git checkout C3; 
  • git checkout HEAD^;
  • git checkout HEAD^; 
  • git checkout HEAD^

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.

Friday, October 26, 2018

Lesson 4.1: Can I recover a branch after its deletion in Git?

  1. How to recover branch if you deleted it:
         If I run git branch -d XYZ, is there a way to recover the branch? Is there a way to go back as if I didn't run the delete branch command?


Resolve:
Instruction recover step by step:
  • git reflog
  • git checkout [sha]
  • git checkout -b [branchname]
  •