2

I have been the sole developer on a project for several years now and only recently got a second dev (who is even less experienced than me with git and Gitea) on the team. This means that I have a lot of source code that I am very protective of but I do need him to start understanding all of it and start implementing enhancements / bug fixes etc.

We have a convention that he would branch from the master branch, and push his feature branch to the origin (Gitea) from where I can view his code and ultimately merge back to master. While playing around in Gitea I noticed that you can set a branch to "protected" which is what I did for the master branch. This is great as it means he can't accidentally push to master but it means neither can I, once I've merged his feature branch to master locally.

Any advice on how to go about this? I don't want to unprotect master every time I need to merge changes and then protect it again.

Dewald Swanepoel
  • 1,651
  • 4
  • 15
  • 38

2 Answers2

3

You won't be forced to "unprotect" your master branch when you want to merge things in. You'll have to create a pull request.

It's only mildly unconvenient to create a branch from master, merge your changes into it, then merge it back into master, compared to an unprotected setting, where you'd push directly to master.

When one of you needs to merge things into master from his feature branch, just push to the remote and create your pull request from there.

In the context you describe, protecting the master branch seems a good idea, not only to prevent newbie mistakes, additionnally it'll give you a nice pull requests history to check in case of trouble.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
3

I have never used Gitea, but at least on other platforms like BitBucket or GitLab you can configure the repository to allow certain people to push to protected branches. Looking for such an option might help. You'll need such an option in case of merge conflicts anyway... (unless you solve them in the source branch)

A quick seach in the internet shows that such a functionality seem to have been implemented already. See the following Pull Request: https://github.com/go-gitea/gitea/issues/32

andreee
  • 4,459
  • 22
  • 42
  • 2
    Thanks. I have scrutinised the configuration sections and couldn't find anything like authorised users or whitelisting. Turns out we have an older version of Gitea. I'll see if I can convince the system admins to do something about that. – Dewald Swanepoel Mar 18 '19 at 12:48