Git — branching and merging

Branching and merging show the real power of git.

Takeaways:
HEAD points to the active branch
Master is the name given to the pointer of the default/main branch and points the last commit

Types of branches:
ahead — this branch is in front of the Master branch and is created with git branch branch-name master
divergent — this branch is an offshoot of the Master branch and is created with git branch branch-name (Note no master keyword)

To switch active branch: git checkout branch-name

* = commit
— .. — .. — master = points to the last commit on the master branch
….. brnch1 = ahead of master (and is the active branch) and points to the last commit on this branch
— brnch2 = divergent from master and points to the last commit on this branch


 

Git branching before merge

Git branching before merge

 

Merging branches
Types:
fast forward
regular
Be careful when merging!! You merge into the active branch which is usually the master branch