Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS: Difference between default and compare branch

Tags:

azure-devops

In my git repository I have three branches: master: default, dev: compare, and temp.

enter image description here

When I create a Pull Request from temp branch it defaults to dev as the target.

enter image description here

It is in contradiction with what Microsoft documentation says:

Change the default branch used to merge code into when your team creates new pull requests. This is useful when you want to use a branch other than master for the main line of development in your repo.

Am I missing something?

like image 342
Hans Avatar asked Feb 19 '18 05:02

Hans


People also ask

What is a compare branch?

Comparing branches provides an overview of differences between two branches which can be very helpful before creating a pull request, merging, or even deleting a branch.

Which branch can be set as compare branch in Azure DevOps?

Update your compare branch to see how far ahead or behind your branches shown on the page are to another branch in your repo: Select the ... next to the branch you want to set as the baseline for comparison. Select Set as compare branch.

How do I compare two azure branches?

From your web browser, open the team project for your Azure DevOps organization. In the Repos > Branches view, select the ellipsis for any branch and choose Compare branches to open the Branch compare view. In the Branch compare view, choose the two branches that you want to compare.


2 Answers

For default branch, it helps you to treat the branch as default when cloning the git repo locally or creating a PR.

Such as if you treat master branch as default branch (by default), when you cloned the git repo locally, the local branch is master. And when you creating a PR, it will automatically treat master branch as the target branch.

For compare branch, it helps you to decide how many commits on the other branches are behind or ahead by comparing commits on other branches with the compare branch.

enter image description here

Such as for above example, develop branch is compare branch, and master branch and nn1 branch are compare with develop branch.

For comparing master branch with develop branch, there has 0 commits behind and 0 commit ahead (master branch same as develop branch). For comparing nn1 branch with develop branch, there are 3 commits behind and 48 commits ahead.

like image 164
Marina Liu Avatar answered Oct 21 '22 10:10

Marina Liu


I did some quick tests in my VSTS tenant. It looks like the default branch of a new pull request is always the Compare branch, rather than the Default branch. So if you set your master branch as Compare branch, it should become to the default for new pull requests.

Not sure if it is bug of VSTS, or if they change the behavior of pull request without updating the doc.

Update:

I did some further research. It turned out that this change was introduced in a Oct 2016 feature roll out:

You can now set your compare branch to something other than the default branch. This setting will be remembered on a per-user basis. Pull requests and new branches created from the Branches page will be based off the branch you set as the compare branch.

So the doc needs to be updated.

like image 27
Chun Liu Avatar answered Oct 21 '22 08:10

Chun Liu