main branches locally
main branches locally
Posted Oct 24, 2025 10:00 UTC (Fri) by gioele (subscriber, #61675)In reply to: main branches locally by mathstuf
Parent article: Git considers SHA-256, Rust, LLMs, and more
>
> If upstream ever rewrites history, the `ff-only` can leave you stranded. I prefer to just always trust what the remote repo is.
Agreed. What I meant was "ff-only" by default. If a pull cannot be fast-forwarded then I definitely want to know about it. I will mostly likely pass some option that says "it's OK, overwrite the branch instead of merging it", but I want to be in control of that.
> > 3) prevent direct pushes to $UPSTREAM-REPO (I may have admin access to that repo, but our workflow is PR-based),
> > 4) block commits to the `main` branch (all development should happen in feature branches).
>
> Branch protection rules (i.e., server-side git hooks) should handle these situations. There's nothing to be done on the developer's side for these as I want the server to enforce them.
As an admin I should have the ability to push whatever I want (or need) to any branch. But that's a big gun pointing at my foot, so I'd like my local tools to not allowing me to do that by default and then shout loudly when I ask them to do it nevertheless. Server-side hooks can be used to implements something similar, but IMO they should be used to solve problems like enforcing policy and access control, rather than as preventive measures for common mistakes.
