How do you merge a Git branch with master?

GitKraken
2 min readDec 4, 2020

Merging branches in Git is useful for combining changes from one branch into another, and for preserving history.

Let’s say you have a master branch with changes. You then branch off into a feature branch and make additional changes.

To merge the feature branch, you will want to first checkout your master branch with

git checkout master

Then use the command

git merge feature

You will then merge changes from the feature branch over to master, adding all changes from the feature branch to master. This gives you an accurate representation of the history, in addition to getting all the changes combined onto master.

ProTip: the term “master” is outdated; we recommend using “main” instead when possible.

Setting your default branch name in GitKraken is quick and easy. You can do this when you initialize a new Git repository in GitKraken, or from the Preferences menu.

Additional Learning Git Resources: Branching in Git | Git Branch Tutorial | How to Delete a Local Git Branch | How to Delete a Remote Git Branch

Originally published at https://gitkraken.com.

--

--

GitKraken

Creators of the world's most powerful suite of Git tools: GitKraken Client, GitKraken CLI, Git Integration for Jira, GitLens for VS Code & IntelliJ (soon).