= git workflow = == Update my branch from the latest upstream primary branch == I'm on a feature branch and want it rebased onto the newest primary branch. git checkout main # switch to the primary branch git fetch # get upstream refs git pull # fast-forward local main git checkout # back to the feature branch git rebase main # replay my commits on top of the new main If the branch was already pushed: git push --force-with-lease == Finding the default branch == The primary branch isn't always "main" (e.g. "master"). git ls-remote --symref origin HEAD # ask the remote (network) git symbolic-ref --short refs/remotes/origin/HEAD # recorded at clone (offline) git remote set-head origin --auto # refresh the recorded value gh repo view --json defaultBranchRef -q .defaultBranchRef.name # GitHub