Merge changes from another branch
Merge two branches
It’s good Git practice to ensure your branch is up-to-date with the latest changes before making any changes to your branch, committing, and merging. To do this, use the Pull remote changes action.When merging, the changes from the branch designated as Merge from are merged into the local copy of your current branch, designated as Merge into. This means you can validate the changes in your local branch before pushing them up to the remote repository.
- Commit the changes you have made on your source branch.
- If you want to merge from the Remote copy of the source branch, push your commits to the remote repository first. To merge from your Local copy, you can skip this step.
- Switch to the branch you want to merge changes into, i.e. your target branch.
- Click the name of your branch on the project bar.
- Click Merge from branch in the drop-down menu.
- The Merge changes from another branch panel shows the branch you are merging from (the source branch) and the branch you are merging into (your current, local branch).
- Select the branch you want to merge from. The drop-down displays every branch in the current project.
- For Location, select Remote or Local to choose which copy of that branch to merge from. Select Local to merge in changes that exist only in your workspace.
- Enter a Merge commit message. You can leave the default message, or replace it with one that has more detail about your changes, but you can’t leave the field blank.
- If there are no merge conflicts detected, click Merge. Otherwise, see Resolving merge conflicts, below.
- Once you click Merge, the changes are integrated into your current branch. A merge from a Local source creates the merge commit in your workspace only—push it when you’re ready to share it with your collaborators.
Resolving merge conflicts
A merge conflict occurs when you try to perform a merge of two branches that each contain changes to pipelines of the same name. Since a branch can’t have two pipelines of the same name, when you merge the branches, only one of the pipelines can be kept. If there is a merge conflict when you use the Merge from branch action, the Merge changes from another branch panel will warn you and require you to resolve the conflict before proceeding. To resolve merge conflicts:- In the Merge changes from another branch panel, in the table listing the files that contain conflicts, click Resolve conflicts.
- In the Resolve conflicts panel, you can see the difference between the local and remote versions of each conflicted file.
- For each file, select either Keep remote to keep the version in the remote branch you are merging from, or Keep local to keep the version in your current branch.
- After you have selected a version of each file to keep, click Save & Continue.
- Enter a Merge commit message. You can leave the default message, or replace it with one that has more detail about your changes, but you can’t leave the field blank.
- Click Merge.
