upvote
> For that reason I always use a git config variable to reference such branches. In my global git config it's main

    $(git config user.primaryBranch)
What about using git's own `init.defaultBranch`?

I mean, while useless in terms of `git init` because the repo's already init'd, this works:

    git config --local init.defaultBranch main
And if you have `init.defaultBranch` set up already globally for `git init` then it all just works
reply
Hmm that might be nice actually. I like not conflating those two things, but as you say if the repo is already init'd then there's no chance it'll be used for the wrong purpose.

In any case the main thrust was just to avoid embeddings assumptions about branch names in your scripts :)

reply
You can pull another branch without switching first:

  git switch my-test-branch
  ...
  git pull origin main:main
  git rebase main
reply
You can also rebase directly on the remote branch

    git fetch
    git rebase origin/main
reply
Nice. That'll make things a bit smoother. Changing branches often trips me up when I would later `git switch -`.
reply
Likewise with the other way around, just switch pull with push.
reply
I have always done `git pull origin main -r`
reply