GIT: How to protect the branch from being removed by other developers?

后端 未结 5 1867
情歌与酒
情歌与酒 2021-02-19 20:29

After the first release of our product, we will be switching to a different branches for the main development and feature development. Is there a way to create a branch in such

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-19 21:25

    I have a git branch model which has dev/master/production branches used for staged deployments, so there are branches that I want protected against deletion. I use pull requests and Visual Studio Team Services, so after each pull request from dev to master for example, VSTS would ask if I would like to delete the source branch (dev).

    I was worried about a developer accidentally deleting dev or another important branch which is used for deployments so I used this hack:

    I created a branch off of dev called "save", made a one line change, opened a pull request against dev, and just leave it open.

    As long as there is an open pull request against dev, dev cannot be deleted and VSTS will not ask if I would like to delete the branch.

    If there is any other more official solution to this problem, I'd be happy to use it. But for now, this was easy and works.

提交回复
热议问题