Change default and compare branch in VSTS

Part of the source code management is to be able to quickly determine the difference between your branch and the main development branch. Usually this happens to be the master but this can quickly change if you are following feature based development or trunk based development. VSTS has the concept of the compare branch where it would provide the number of commits ahead or behind data for all other branches. This helps one in quickly determining the related information by just taking a glance at the branch page.

To set a different branch as the compare branch, select the branch in the reference and click on the three dot icon:

Set another branch as the compare branch
Set another branch as the compare branch

Once its set, we can see that the compare label will shift to the newly selected branch:

compare label will shift to newly selected branch

Default branch is the branch which will be auto selected to merge code into, when someone creates a pull request. Again, this is usually the master branch. To change this to a different branch, first we need to get into the manage repository view or go to project settings -> repositories. After this, click on the git repository in the reference and then expand ‘branches’ for all the branches. After this select the … next to the branch you want to set as default, then select ‘Set as default branch’:

Set another branch as default branch
Set another branch as default branch

It may appear that instead of the default branch, pull requests and new branches created from the branches page will be based off the branch you set as the compare branch. However this setting is remembered on the per user basis. Setting the default branch is a way to set the default for your entire team. It is a way to set a reasonable default for when new users use your repository. However, if a user wishes they can diverge from the default by setting their own ‘compare’ branch.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s