What is a git branch?
A branch is just a pointer which points to a specific commit.
What is HEAD in git?
The HEAD in Git is the pointer to the current branch reference, which is in turn a pointer to the last commit you made or the last commit that was checked out into your working directory.
What is git merge?
The git merge command lets you take the independent lines of development created by git branch and integrate them into a single branch.
Types Of Merge
Fast Forward Merge
A fast-forward merge can occur when there is a linear path from the current branch tip to the target branch.
If Master has not diverged, instead of creating a new commit, git will just point master to the latest commit of the feature branch. This is a โfast forward.โ
There won't be any "merge commit" in fast-forwarding merge.
Note:
During fast forward merge If there is a need to create a merge commit for record keeping purposes you can execute git merge with the git merge --no-ff
option.
3 Way Merge
When there is not a linear path to the target branch, Git has no choice but to combine them via a three-way merge. This merge uses an extra commit to tie together the two branches.
Now, we are familiar with basics of branching and merging. We will continue in the next part on brnaching and merging workflow.
Thanks for reading! ๐