drewdeponte / git-ps-rs

Official git-ps Rust implementation - the future of git-ps
https://git-ps.sh
MIT License
78 stars 8 forks source link

Investigate if there is a way to prevent push to main when using gps #274

Open drewdeponte opened 10 months ago

drewdeponte commented 10 months ago

The idea is to see if there is a way to prevent a push to main when using gps. Or maybe configure branches with .git/config in such a way where it is safer if a git push happens.

Maybe having where a push happens could be different from where a pull happens with a branch configuration in .git/config? Or maybe there is some other option in the .git/config I am not aware of that would aid with this.

https://git-scm.com/docs/git-config

trcoffman commented 10 months ago

I've figured out that the best way to prevent accidentally pushing your patchstack to remote (especially important when your patchstack is main) is to configure the branch's pushRemote to be a different remote.

For instance, you can have a fork remote of your repository and do something like git config branch.main.pushRemote fork.

Your patchstack's upstream branch can still be origin/main or something like that, but it'll push to fork/main instead. GPS will still work as you expect and create PRs for you targeting origin/main.

Another thing that I did is to rename origin to upstream in case some tooling doesn't respect config and just pushes to origin without looking at config. This will prevent those primitive tools from working and pushing when you don't want them to.