How to Merge Develop Into Feature in Git

Abdul Jabbar Feb 02, 2024
How to Merge Develop Into Feature in Git

Creating new branches and merging them is considered the most powerful tool of Git. Git’s feature of creating new branches and merging them into the development code is very useful for the developers to work in a team environment.

This feature simplifies the development process for basic projects by motivating smaller and more powerful commits. This guide will discuss different scenarios of creating a feature branch and merging the Git feature branch with the master branch using Git commands.

Git Merge Develop Into Feature

If we use branches assigned to features or hotfixes, we create branches from other branches to work on our desired project. If we create a branch from another branch, it is as simple as creating it from the main branch.

For that purpose, we have to specify the name of the other branch that we want to use as a starting point. We will create the feature branch feature2 from the develop branch through the below-mentioned code.

So, all the files and code of that branch will be merged into our specified branch.

git checkout -b feature2 develop

After we checkout the new branch above, feature2, we will check out the developed branch below to fetch changes and merge them into the above branch.

git checkout develop

We will first pull the changes from the develop branch through the git pull command. The git pull command will fetch the content from the develop branch and update the content into the feature2 branch.

git pull

Now we will check out the local branch through the command stated below.

git checkout feature2

After that, we will perform the merge option. The option below helps us integrate the differences from one branch to another.

For performing this option (merge), we have to specify which branch’s commits we want to integrate.

git merge feature/login

As we know that Git performs integrations automatically, but sometimes it results in merge conflicts that users have to solve by themselves. We have another option for merging.

We can also perform the following operation if we are on our feature branch, feature2.

git fetch && git rebase origin/develop
Author: Abdul Jabbar
Abdul Jabbar avatar Abdul Jabbar avatar

Abdul is a software engineer with an architect background and a passion for full-stack web development with eight years of professional experience in analysis, design, development, implementation, performance tuning, and implementation of business applications.

LinkedIn

Related Article - Git Merge