Pushing and Upstreams

Pushing Branches and Setting Upstreams

git push <remote> <branch> uploads missing objects and asks the remote to move its branch, only as a fast-forward unless forced. A new branch has no upstream, so a bare git push fails:

Pushing a new branch and setting its upstreamShell
git switch -c dev-docs
# Edit README.md: add a Development section about npm run dev
git commit -qam "Document npm run dev"
git push
git push -u origin dev-docs
Output
Switched to a new branch 'dev-docs'
fatal: The current branch dev-docs has no upstream branch.
To push the current branch and set the remote as upstream, use
    git push --set-upstream origin dev-docs
...
To ../server/booknest.git
 * [new branch]      dev-docs -> dev-docs
branch 'dev-docs' set up to track 'origin/dev-docs'.

-u pushes and records the upstream, so plain git push and git pull work from then on, and push.autoSetupRemote true makes every first push do so. The default push.default=simple pushes only the current branch, to its same-named upstream. git push origin --delete <branch> deletes a remote branch.