Site icon Data Cuisine

Database Projects – Merging changes

Header Database Projects & Azure DevOps

In my previous blog post (Database Projects – Making Changes), we successfully executed our first development task in a feature branch. To get our changes to the development environment, we will need to execute a couple of steps which are called merging.

Quick Overview

What is merging exactly?
Merging by example
Lessons Learned

What is merging exactly?

When you start development, you create a feature branch, which is a living copy of your main branch where you apply changes during the development phase. As soon as you finalize your development, you want to get these changes to your development environment.

This process is called merging. During the merge process, 2 branches will be combined. At this point, we want our feature branch to be combined with the development branch.

Merging by example

To get started, make sure that you have Visual Studio open and that you have opened your Database Project. As soon as everything is loaded properly, navigate to the bottom right corner where you can see which branch is currently checked out. In my case, the feature/demo-ticket-1 branch is checked out.

Now, let’s click on the branch name and explain what you are currently looking at.

As you can see, feature/demo-ticket-1 is marked in bold. This means that this branch is currently checked out and active on your local machine. As you will see as well, I currently have 3 branches available on my local machine: development, feature/demo-ticket-1 and master.

In case you don’t have a development branch yet, you can create a new branch called “development” based on the master branch.

Now click on the development branch to make sure this branch is checked out, to validate, take a look at the right bottom corner and check if the development branch is activated.

Up next, we need to ensure that we have the most recent version of the development branch available on our local machine. To do so, navigate to the Git section in the menu bar, click Git and choose Pull. This will pull in all changes from the remote development branch and make sure that your local version of the development branch is up to date.

During the next step, we will be executing the actual merge process. To do so, navigate to the bottom right corner of Visual Studio, click on the development branch and then right-click on the feature/demo-ticket-1 branch. As all options will be shown, you will see “Merge into Current Branch”. Confirm by left-clicking on this option.

Visual Studio will now warn to ensure that the merge process will be executed intentionally. Since we want to get our changes in the development branch, confirm by clicking Yes.

As soon as you have confirmed, Visual Studio will start to execute the merge of the feature branch with the development branch in a backend process. What is important to remind is that you always need to check out the branch you want to merge to and you need to make sure that you first get the most recent changes in by pulling before you start the merging process.

Now you can navigate to the Git Changes pane in Visual Studio (Menu bar: View –> Git Changes), As soon as the merge process has finished you will something similar to:

As you can see in the screenshot above, there is 1 outgoing change (in my case) ready to be pushed to the remote. To finalize the merge process, click the push icon in the Git Changes pane. As a result, you will get the following message:

If you want to validate your push, you can quickly navigate to Azure DevOps, and go to your repository. Make sure you change to the development branch to check your changes.

As soon as you complete the merge process, you can deploy your changes to the development environment. If you are wondering how to deploy, l go through the deployment process step by step in the following blog post: Database Projects – Deploying Changes.

Lessons Learned

If we need to summarize the most important steps when you want to merge:

Exit mobile version