News for hackers. Stuff that matters.
Re:I Kind of Like Rebasing by smcameron on Saturday June 22, 2024 @09:42PM (#40763937)
> Then you can safely git push --force

What I hate about this workflow is it teaches you to git push --force.

Then one day, you're in the wrong window and you accidentally git push --force on master.

Much prefer a workflow where you never git push --force

Re:I Kind of Like Rebasing by necessary on Saturday June 22, 2024 @10:25PM (#40764210)
Git hosting platforms generally have controls that allow you to prohibit force pushes on protected branches (i.e. master)
Re:I Kind of Like Rebasing by The_Colonel on Sunday June 23, 2024 @01:14AM (#40764985)
This doesn't fix the problem since you still can do a lot of damage doing that on a (perhaps wrong) feature branch.
Re:I Kind of Like Rebasing by SOLAR_FIELDS on Sunday June 23, 2024 @02:19AM (#40765165)
It certainly diminishes it significantly. Very few people are usually collaborating on the same branch together that isn’t the main branch in most orgs. So the chances of you destroying yours or someone else’s work that way is pretty low. You can also branch protect any arbitrary branch, at least on GitHub, though I’ve never been in an org that protects branches other than the main one, besides an org that used release branches. I’ve also never seen someone clobber someone else’s feature branch, though it probably does happen. Much more often people are accidentally clobbering their own branches.

The ability to rewrite history on feature branches is powerful in a good way and slots right into the way Git is philosophically designed. I would probably not be interested in removing that feature to prevent the rare case that someone footguns themselves or someone else

Re:I Kind of Like Rebasing by nickkell on Sunday June 23, 2024 @03:49AM (#40765506)
That's where reflog comes in handy
Re:I Kind of Like Rebasing by zimbu668 on Saturday June 22, 2024 @11:00PM (#40764402)
You should do this instead:

git push —-force-with-lease repo branch

Re:I Kind of Like Rebasing by ajb on Sunday June 23, 2024 @01:13AM (#40764980)
This. --force-with-lease is what --force should have been in the first place. Hopefully they will eventually make it so, and rename --force to something less accessible.
Re:I Kind of Like Rebasing by cortesoft on Sunday June 23, 2024 @12:50AM (#40764893)
Any repo worth its salt shouldn't allow a force push to the main branch.
Re:I Kind of Like Rebasing by ck45 on Sunday June 23, 2024 @04:06AM (#40765577)
I fully agree, and also think that if it's a professional environment pushing to the main branch itself is very questionable for most / code repos. Not only because of the Sarbanes-Oxley Act for public companies.