In my git
repository I have three branches: master: default, dev: compare, and temp.
When I create a Pull Request
from temp branch it defaults to dev
as the target.
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?
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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With