Git Merge Develop Into Feature

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
Write for us
DelftStack articles are written by software geeks like you. If you also would like to contribute to DelftStack by writing paid articles, you can check the write for us page.

Related Article - Git Merge

  • Git Merge Repositories
  • Merge Local Branches in Git
  • Merge a Remote Branch to a Local Branch in Git