Search
Close this search box.

Git Merge

When working in Git, the merge action is used to combine changes from one branch to another, such as Git merge to master.

Merging can also be helpful for preserving your repo history. Particularly when comparing Git merge vs rebase, merging preserves a more complete history, and makes it easier to undo mistakes.

We’re going to walk through the process of how to merge using the legendary cross-platform GitKraken Git client before going over how to use the Git merge command in the CLI.

Merge your branches faster and with more control using GitKraken

How do you merge in GitKraken?

One of the largest benefits GitKraken offers as a Git GUI is the ability to quickly visualize all of the branches in your repository and manage those branches intuitively with drag-and-drop actions.

In this example, we have a dev branch containing changes we wish to merge into the production branch. To begin the process of a Git merge branch in GitKraken, you can simply drag-and-drop the dev branch onto the production branch.

Now, if you didn’t already have the dev branch checked out, GitKraken would ask if you want to first checkout the branch. See, told you it was intuitive. 😉 Moving on…

After you drag-and-drop the branch with changes onto your target branch, you can click the Merge dev into production option from the context menu. If there are no conflicts, the merge commit will go through and all of your changes will now be merged onto the production branch.

How do you resolve a merge conflict in GitKraken?

Now, if you run into a Git merge conflict, GitKraken will pause the merge and immediately inform you that a file conflict was found.

Better yet, GitKraken’s merge conflict tool will guide you through the resolution process, giving you all the information you need to decide which changes to keep and which to discard.

From the commit panel on the right of the main GitKraken UI, click on any conflicted file to enter the GitKraken merge conflict tool.

Each conflict section will appear with an accompanying checkbox. Checking a section’s box will add it to the output section at the bottom of the merge conflict tool. This allows you to see all of your available options with complete context before you decide how best to proceed.

Once you’ve made your choices for each file conflict, you can move forward with saving and completing the Git merge.

Shed light on the dark world of merge conflicts with GitKraken

How do you Git merge in the command line?

If you’re using the CLI to merge changes in Git, a typical workflow will start by running the git status command to check for any pending changes on your feature branch.

In this example, there are some changes that need to be committed, so let’s start there. You will start by staging the file:

git add <file name>

Followed by a commit:

git commit -m “<commit message>”

GitTip: If you’re new to Git, get more comfortable with how to commit changes before you advance to merging.

Now that we’ve committed our changes, we are ready to merge the feature branch into the dev branch.

But before we can Git merge in the command line, we will have to checkout the target branch we wish to merge our changes into, in this case dev.

git checkout dev

GitTip: Not sure how to checkout a Git branch? Learn how to switch local branches, and how to checkout a remote branch.

In this example, the command line is telling us that the dev branch is behind. In this case, you will want to perform a Git pull to get the latest updates before moving forward with a merge.

GitTip: Learn how to pull a remote Git branch to keep your local branches up-to-date.

OK, now you’re ready to move forward with a Git merge. In the command line, you will use the Git merge command followed by the branch containing your changes.

git merge feature

Next, you will see a prompt asking for a merge commit description. From here, you can either edit the default commit message or move forward by saving and closing the message editor to complete your merge in the command line.

Get more control over your merges in Git and never worry about creating a merge conflict you can’t solve. GitKraken is the way to a better merging experience; download the legendary cross-platform Git GUI for Windows, Mac, & Linux free today.

Additional Resources

Table of Contents

Make Git Easier, Safer &
More Powerful

with GitKraken

Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.