JIYIK CN >

Current Location:Home > Learning > OPERATING SYSTEM > Git >

Merge the development branch into Master in Git

Author:JIYIK Last Updated:2025/04/02 Views:

This article provides an overview of merging a development branch into the master branch. Often we find ourselves creating a branch outside of the master branch for development.

Once we are happy with the changes, we can merge them into master. The question is, which is the safest way to merge the two?


Git merge the development branch into master

For a simpler context, we will use the following example.

The example below shows a repository with a master branch. We will create a develop branch of master and make some changes.

We will see the safest and cleanest way to merge the develop branch with the master branch.

Some people may disagree, but the safest and cleanest way to merge develop into master is to merge master into development first.

This way you can deal with merge conflicts in your development branch. It will keep your master branch intact until you decide what action to take.

To merge our master into develop , we will first switch to the develop branch and run the command below.

$ git merge master

Output:

git merge master

In our case, we have some merge conflicts. When resolving conflicts, you may come across sections that require more work.

Since master has not been touched, you can make some more edits and try to merge master into development until you are satisfied. Now we can merge development into master.

Switch to the master branch and run the command below.

$ git merge --no-ff development

The above merge could very well be fast-forwarded. The downside to this is that Git doesn't create a commit node, which means we can't track when and who did the merge.

--no-ffWe fix this by including the flag to create the commit node .

In short, you can merge the develop branch directly with the master branch. However, you can choose the cleaner and safer route and merge master into develop first , fix merge conflicts (if any), and finally merge develop into master.

Include the flag in the last step of creating the commit node --no-ff.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

Comparison between Git merge and Git rebase

Publish Date:2025/04/05 Views:171 Category:Git

The git rebase command may seem like Git wizardry to beginners, but if used carefully, it can actually make life easier for your development team. In this article, we compare git rebase with the related git merge command and identify all th

Difference between Git Merge Origin/Master and Git Pull

Publish Date:2025/04/03 Views:196 Category:Git

This article outlines the differences between the git merge origin/master and git pull commands. These two commands integrate changes from a remote repository into the current local branch. However, each command's operation is unique and ha

Git Pull and Merge Commands

Publish Date:2025/04/03 Views:57 Category:Git

In the vast world of version control systems, Git is the only fast, well-organized, in-demand, and easily accessible version control system that enables users to work on various projects simultaneously in an efficient manner without any col

Difference between Git Merge Master and Git Merge Origin/Master

Publish Date:2025/04/03 Views:180 Category:Git

This article outlines the differences between the git merge master and git merge origin/master commands. We use both of these commands to integrate changes from the master branch. The difference lies in when and how to use them, which we wi

Git merge development branch into feature branch

Publish Date:2025/04/02 Views:128 Category:Git

Creating new branches and merging them is considered to be the most powerful tool of Git. The ability of Git to create new branches and merge them into the development code is very useful for developers working in a team environment. This f

Complete the merge after resolving conflicts in Git

Publish Date:2025/04/02 Views:64 Category:Git

This article describes the process of completing a merge after resolving merge conflicts in Git. We will go through the merge steps, resolve the conflicts, and complete the merge. Complete the merge after resolving conflicts in Git For a si

Recovering a conflicting Git merge

Publish Date:2025/04/02 Views:162 Category:Git

This article explains the revert command when a merge conflict occurs git merge . We will also take a quick look at how to undo a git merge that was successful and has been pushed to a remote repository. Recovering a conflicting Git merge I

Git merge test run

Publish Date:2025/04/02 Views:103 Category:Git

This article will discuss resolving git merge conflicts through git commands. Overview Git has many features which developers can use easily and solve their problems. Among these features of git, merging is the basic aspect that every devel

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial