Restricting push access to master branch

(Jason Gaudette) #1

I have started to have my students use a pull-request to confirm when they have completed an assignment. This allows students to work on their own branch and get familiar with the branching workflow for group projects.

Although I am able to add a ‘student’ branch to the template in GitHub classroom, the branch restrictions I place on ‘master’ do not carry when students accept the assignment and import their repositories.

Question: Is it possible to modify the GitHub Classroom starter template repository so that student repos will only allow TAs and instructors push to the ‘master’ branch?

Thanks!

Jason

5 Likes
(Mark Michon) #2

A recent change has made it so the protected master settings don’t carry over, but there’s an active issue on the GitHub classroom repo about it. I’ve been manually setting it on each student repo for now. I believe there’s still API access to set branch protection, so you could set up a web hook that does it. (this is what I’ll eventually get around to for my workflow).

2 Likes
(Brian Simpson) #3

Any updates on your problem? I’m having the exact same issue at the moment. I have not tried editing the settings of each student’s repo, but that is next on my idea list.

(Mark Michon) #4

For those looking for a pretty close to turnkey solution, I put something together with Probot and Glitch.

When GitHub classroom creates the student’s repo, this app will create a protection rule on master that requires 1 pull request review before a merge can take place. I should note that this uses an experimental GitHub API, but I’ll keep an eye on changes and hopefully it won’t break unexpectedly.

Two ways to get this up and running:

In the future I’ll be putting together some writeups on using Probot to fill in some of the gaps with Classroom. Hopefully sooner rather than later :sweat_smile:.