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]
  •   

Wednesday, October 17, 2018

Learn1: The first session about git

1. Git commit:
a. Currently:



b. Goal:


 Commandline:
  • .git checkout master
  • git commit -m"This is comment" .




Lesson2: Create new branch and checkout

  1.  Curently:

  1. Goal: 

Git command:
  •  git branch bugFix
  • git checkout bugFix
Other: If you want to simple, you can type command line
  • git checkout -b bugFix

Lesson3: Git merge

Now we need to learn some kind of way of combining the work from two different branches together. This will allow us to branch off, develop a new feature, and then combine it back in.

Merging in Git creates a special commit that has two unique parents. A commit with two parents essentially means "I want to include all the work from this parent over here and this one over here, and the set of all their parents.".

  1. Let's merge master into bugFix:
    git checkout bugFix; git merge master

    Since bugFix was an ancestor of master, git didn't have to do any work; it simply just moved bugFix to the same commit master was attached to.

    • Make a new branch called bugFix
    • Checkout the bugFix branch with git checkout bugFix
    • Commit once
    • Go back to master with git checkout
    • Commit another time
    • Merge the branch bugFix into master with git merge
     Start:

    Goal:





    :
     











Git command line:
                         $ git checkout -b bugFix
                         $ git commit
                         $ git checkout master
                         $ git commit
                         $ git merge bugFix