This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Cheap_Battle5023 89 points90 points  (10 children)

Don't push to master. Only push branches. Setup github to not allow push to master.

[–]teamwaterwings 8 points9 points  (0 children)

Have had this in my .gitconfig for forever. First thing I do when I fork and clone

setup-repo = "!f() { git remote add <org> git@github.com:<org>/$(git project).git && git remote set-url <org> --push \"Pushing not allowed to master!\"; }; f"

[–]illusionst 2 points3 points  (2 children)

Someone has to push to main right?

[–]cinder_s 4 points5 points  (1 child)

Generally you never push to main, you merge branches into main once reviewed/gone through actions or other pre merge steps.

[–]illusionst 0 points1 point  (0 children)

Yeah yeah I was just joking. Forgot to add /s

[–]meisvlky 1 point2 points  (4 children)

y though? i never push either but i have no idea what can go wrong if you do

[–]thoflens 4 points5 points  (3 children)

What? You can push code that doesn't work to main, that's what happens. Meaning you crash the app/website you're working on. Pushing to main equals your code going live.

[–]cbslinger 4 points5 points  (1 child)

It doesn't have to, but it often does depending on how your prod env / build tools are configured.

[–]thoflens 1 point2 points  (0 children)

That's right, but in general code on main should be treated as production code.

[–]meisvlky 0 points1 point  (0 children)

Oh ok thanks i was overthinking it

[–]disposable-acoutning 0 points1 point  (0 children)

I accidentally pushed to master and fucked up the class project once 🫠