本文介绍了TFS-Git分支机构政策的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难理解分支机构的政策,我正在阅读以下文章 https://www.visualstudio.com/zh-cn/docs/git/branch-policies .

I am having a hard time understanding branch policies, i was reading through the following article https://www.visualstudio.com/en-us/docs/git/branch-policies.

  1. 也许我读错了,但为什么在pull上设置了警察,却没有push似乎在过程中有点晚了
  2. 为什么您不能阻止用户合并/推送,所以说一个分支变成另一个分支?
  1. Maybe i am reading it wrong but why are polices set on the pull and notthe push seems a bit late in the process
  2. Why cant you block users from merging/pushing lets say one branch into another?

我希望能够将features推送到我的master branch中,但是我从不希望有人将我的develop branch合并到master branch

I want to be able to push features into my master branch but I don't ever want someone to merge my develop branch into the master branch

你能做类似的事情吗?

推荐答案

分支策略类似于TFS中签入策略的概念.在启用签入策略之后,要求用户在对源代码管理执行签入时采取措施,例如,可能要求用户将工作项与变更集相关联或添加签入注释.

Branch policy is something like the concept of check in policy in TFS. After enable check in policy, the user is required to take actions when they conduct a check-in to source control, for example a user can be required to associate a work item with a changeset or add a check in comment.

以同样的方式,在设置分支策略之后,您将无法直接将更改推送到分支. 仅通过请求请求才能更改分支.

In the same way, after you setting up a branch policy, you cannot directly push changes to the branch. Changes to the branch are only made through pull requests.

Pull request是TFS中的功能名称,与git中的pull/push概念无关.

Pull request is a feature name in TFS, it's nothing business with the concept of pull/push in git.

对于阻止用户合并/推送,这是TFS中的另一个概念权限.只有具有 Contribute 权限的用户才能将新的提交推送到分支并锁定该分支.如果您对此感兴趣,可以在这里看看:设置分支权限-GIT

As for block users from merging/pushing, it's another concept Permission in TFS. Only users with Contribute permission can push new commits to the branch and lock the branch. If you are interested in this, you could take a look at here: Set branch permissions-GIT

要将功能推送到我的master分支中,可以使用git命令

To push features into my master branch, you could use git command

git push origin branch1:branch2

更多详细信息,请参考以下问题:将提交提交到另一个分支

More details please refer this question: Push commits to another branch

因为我永远都不想有人将我的开发分支合并到master分支中.您可以设置您的开发分支的权限,只拒绝在开发分支上其他人的贡献权限.(注意:这也将不允许他们对您的开发分支进行推送提交,TFS Git中没有任何仅与合并相关的权限)

For I don't ever want someone to merge my develop branch into the master branch. You could set the permission of your develop branch, just deny other's Contribute permission on the develop branch.(Note: this will also disallow their push commits to your develop branch, there is not any only merge related permission in TFS Git)

如果要使用分支策略,可以通过设置必须通过代码审查来防止其他人合并您的develop分支.但是,您将无法直接将功能推入master branch中.详细原因仅需参考 Martin的答案中的第二段.

If you want to use branch policy, you could prevent others merging your develop branch by setting must pass your code review. However, then you could not directly push features into the master branch. The detail reason just refer the second paragraph in Martin's answer.

另一种解决方法是临时锁定您的开发分支防止可能与重要合并冲突的新更改或将分支置于只读状态的理想选择.

Another workaround is temporary locking your develop branch which ideal for preventing new changes that might conflict with an important merge or to place a branch into a read-only state.

这篇关于TFS-Git分支机构政策的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 20:06