Branching and Merging
Learn how to branch and merge in GitKraken. 🌳 🔀
When starting work on a new feature or bug, create a new branch. Right click on any existing commit to create a branch:
A branch is a pointer to a specific commit in the repo, rather than making entire copies of the working directory files.
Branches allow you to isolate new work from other areas of the repository, and consider implementing GitFlow as a merging strategy.
Checking out branches
Branch checkout updates files in the working directory to reflect the version defined by that branch.
New commits are added to the checked out branch. If you find yourself on the wrong branch, stash your changes, switch to the correct branch, and then pop the stash.
When you create a new branch, GitKraken will automatically checkout the branch for you:
To checkout a different branch, double click on the branch label on the left panel or via the graph. Checkout is also available by right-clicking a branch.
Merging takes the commits on two different branches and combines them.
With a merge, files are automatically merged unless there are two conflicting set of changes, i.e. commits on the different branches updating the same line in different ways.
Drag and drop one branch onto of another to initiate a merge, or just right click the branch you would like to merge in and select merge from the menu.
Choose your own adventure
- I want to merge my own stuff in -- Bravely continue onward!
- I want someone else to review and merge for me! -- You want a Pull Request!
GitKraken Merge Tool
If your merge attempt triggers a merge conflict, GitKraken will display each of the conflicting files on the right.
Clicking a conflicted file opens the Merge Tool.
The current branch is on the left, and the target branch that you're merging into is shown on the right. The Merge Tool output is at the bottom.
Each conflict section has a checkbox. Checking a section adds it to the Output at the bottom.
Mouse over the line number and click to select specific lines for the Output, or edit the Output window directly.
Clicking the up and down arrows will move you to the next conflict.
After the conflict is resolved, save the output and commit the changes.
External merge tools
Configure GitKraken to launch your tool of choice by navigating to Preferences General:
GitKraken currently supports the following merge tools:
- Beyond Compare
If your merge tool from the list above is installed and is not showing up in the dropdown, then look for an option to install command line tools.
GitKraken does not support the following merge tools:
While GitKraken allows Git Config Default merge tools, not all tools will be compatible. Find more information about configuring a default merge tool in your Git Config.
Rebasing takes the commits from one branch and places them onto the last commit of another branch. This alters the tree structure by moving the commits and their changes onto the target branch.
To perform a rebase, drag and drop one branch onto another branch then select Rebase.
You can rebase onto a local or remote.