Cheatsheet Pages / Git Cheatsheet

How to push a branch and set its upstream — git push -u

You are pushing a branch for the first time and want future pushes to need no arguments.

git push -u origin feature/login              # first push: publish + set upstream
git branch --set-upstream-to=origin/main main  # re-point an existing branch's upstream

Good to know

-u links your branch to the remote so future git push / git pull need no arguments.

Git Cheatsheet one-page card — 30 daily and rescue commands
The full one-page card — Git Cheatsheet. Get the complete cheatsheet on GitHub