Git Branching and Merging Strategy- Part 1

Git Branching and Merging Strategy- Part 1

ยท

2 min read

What is a git branch?

A branch is just a pointer which points to a specific commit.

image.png

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.

image.png

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.

image.png

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.

image.png

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.

image.png

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! ๐Ÿ˜Š

Did you find this article valuable?

Support Sujeet Agrahari by becoming a sponsor. Any amount is appreciated!