# First push — set the upstream branch
git push -u origin main
# Subsequent pushes (upstream already set)
git push
# Push a specific branch
git push origin feature-x
The -u flag (or --set-upstream) links your local branch to the remote branch, so future git push / git pull know where to go without specifying the remote and branch every time.
Git refuses to push if the remote has commits you don't have locally:
# Remote is ahead — you must pull first
git pull --rebase # get remote changes, put yours on top
git push
git push --force-with-lease # safer: fails if remote has changed
git push --force # dangerous: can destroy others' work
A remote named origin is already configured. Push the main branch to it using -u.
Click "Run" to execute your code.