> Why is it that I can pull from a remote branch, commit some changes, run ‘git push’ and git has no idea what branch I want to push to
Git has automatically tracked remote branches for years now. "git switch foo" will do exactly what you expect if "origin/foo" exists.
> if main is a protected branch, don’t let me accidentally commit to it locally
"Protected branches" don't exist in Git. They're a GitHub concept. How would you be able to fork a repository if the permissions on a remote copy of the repository prevent you from making changes to your own copy?
I can see the case for a local UI option (perhaps even on by default) that warns you when you make changes to a local branch that's tracking a remote branch that's marked as 'protected' there. The option could also have a setting where it outright stops you from making that change.
Of course, you could always opt out of that setting.
Git doesn't know what 'protected' means, but you could teach it with a relatively small change to its code. Similarly, it might be useful to teach git about 'volatile' branches (in the same sense as C's volatile variables); a volatile branch is one where git would always checks for upstream changes first before any operation. Eg origin/main would typically be marked as both protected and volatile.
Again, volatile would be something you can override locally, but it might be useful as a default.
Also, many repo hosts have branch protection tools, and VS Code has a setting git.branchProtection to list branches which you want VS Code to remind you not to commit to, which can be handy.
Git has automatically tracked remote branches for years now. "git switch foo" will do exactly what you expect if "origin/foo" exists.
> if main is a protected branch, don’t let me accidentally commit to it locally
"Protected branches" don't exist in Git. They're a GitHub concept. How would you be able to fork a repository if the permissions on a remote copy of the repository prevent you from making changes to your own copy?