Git Publish New Branch
Description:
It is considered a good practice to publish a new branch called dev_your_id
or something and then set that up for submitting pull requests before merging into a testing
and a main
branch. Here is how I set up my repos lately.
To Resolve:
-
First, get connected to Github Enterprise private repo
-
Next, create a new branch locally and push it to the repo:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
git status # on branch main git checkout -b testing touch myfile git add --all git commit -m 'add myfile' git push origin testing git checkout -b dev_gerry touch myfile git add --all git commit -m 'add myfile' git push origin dev_gerry git status # on branch dev_gerry
-
Next, setup brach protection rules to where you cannot push directly into
testing
ormain
, but first have to get an approval from a pull request:- Inside Github, select the repo and go to Settings => Branches => Branch protection rule
- Check the box: Require pull request reviews before merging => Reviews: 1
- Branch name pattern:
testing
- Copy this a second time to the
main
branch: - Branch name pattern:
main
- On the main rule, make sure to check the box
Include Administrators
-
So what this effectively does is make it to where you can do a pull request from
dev_gerry
totesting
and, if you wish, use your admin privileges on the repo to force a merge between the branches. But you have to get another approver to mergetesting
intomain
or anything intomain
. What I would like to know is how do you stopdev_gerry
from even being able to do a pull request tomain
? Hopefully I will figure this out and update later.
Comments