Push local commits to a remote branch with git push
domain: git-scm.com/git · 6 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗
Documented steps
Confirm your branch and upstream: git status shows 'Your branch is ahead of origin/<name> by N commits'.
Push to the configured remote: git push origin main pushes the local main branch to main on origin. The <repository> argument defaults to the current branch's upstream, or origin if none is set.
For a branch that has no upstream yet, set it while pushing: git push -u origin <branch> (the -u / --set-upstream option records the upstream so later pushes can be plain git push).
Push all branches at once with git push --all, or only tags with git push --tags / --follow-tags.
To delete a remote branch push the empty source: git push origin :remotebranch, or git push origin --delete remotebranch.
Preview without transferring with git push --dry-run.
Known gotchas
git push fails with a non-fast-forward rejection ('! [rejected]') when the remote has commits you do not have; fetch and merge or rebase first.
--force (-f) bypasses the fast-forward check and can cause the remote to lose commits; prefer the safe --force-with-lease, which only forces if the remote ref still matches your expectation.
The remote repository argument defaults to the current branch's upstream, falling back to origin; pushing needs a configured remote.
push.default defaults to 'simple', which pushes the current branch to a same-named branch on the remote — behaviour differs from 'matching' on older git versions.
You cannot set an upstream and force in a way that surprises team members; coordinate forced pushes.
Give your agent this knowledge — and 16,900+ more routes
One MCP install gives any agent live access to the full route map across 5,900+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?