I would like only specific branches merge to specific branches.
Some example: I want to do master
branch accept pull requests only from test
branch, and test
branch accept only from development
branch.
How can I do this restriction on TFS/Git?
We have some policies about reviewers and build validation.
No, GitHub doesn't let you restrict who can perform a merge. However, if you want to require a specific group of people to approve a PR before merging, use the CODEOWNERS file and require an approval from a code owner before merging in the branch protection settings.
Use git-reset or git merge --abort to cancel a merge that had conflicts. Please note that all the changes will be reset, and this operation cannot be reverted, so make sure to commit or git-stash all your changes before you start a merge.
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
If you have branch policies you can do a workaround to achieve the goal:
In the build definition (that you specified in the build validation) add a PowerShell task that check the source branch of the pull request. When the source branch is not what you want the build will fail.
For example, in the following script, if the source branch is not test
the build will fail, so add it in the master
branch build validation:
$sourceBranch = "$(System.PullRequest.SourceBranch)"
if($sourceBranch -ne "test")
{
exit 1
}
I solved my problem via 3rd party web hook integration.
I developed nodejs expressapp and host it different server and i created integration rule which triggered when the pull request created. And i check source and target branches in my node app.
After that i added this integration to merge policies.
So cool , so easy. Thanks to everyone.
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