Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature for protection against pushing to remote main/master #3716

Open
trskare opened this issue Jul 4, 2024 · 4 comments
Open

Feature for protection against pushing to remote main/master #3716

trskare opened this issue Jul 4, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@trskare
Copy link

trskare commented Jul 4, 2024

If you forget to switch branch from master/main and press the key P or perhaps you meant to press p (for pulling) you could in theory do something that could have a big consequence if you work against a repo that are used for CD/gitops/configuration management. Sure! Those repos should definitely have branch protection in place anyway to disable force pushing, only merge commits thru PR/branches etc, but lets think worst case scenario and say someone forgets to enable them or they are temporarily disabled.

What about optional protection feature that will give you a big warning you if you try to push against remote master/main branches?

@trskare trskare added the enhancement New feature or request label Jul 4, 2024
@navignaw
Copy link

navignaw commented Jul 15, 2024

I think this may extend beyond "enhancement" to "bug". I just accidentally pushed my main branch locally to remote by pressing "P", despite the fact that branch protection was configured to require a pull request while reviewing. It would be great if it respected the remote branch protection (or even had a confirmation message to make sure you are certain)

Screenshot 2024-07-15 at 8 21 09 AM

@mark2185
Copy link
Collaborator

Is that really lazygit's fault if your git service didn't protect the branch? It just does git push in the background.

@navignaw
Copy link

I can do a bit more research and try to repro on a fresh git repo, but I'm pretty sure that the cli git push would fail due to the branch protection rule, so I'm honestly a bit confused how this happened.

@navignaw
Copy link

Apologies for the miscommunication. It turns out that this didn't apply because I was an admin of the repo and github (for whatever reason) lets admins bypass branch protections by default, unless this flag is checked. So there's no issue on lazygit's end!

However I'd still like to echo the feature request of adding (maybe an optional config you can set?) a confirmation message before pushing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants