git push
intermediateUpload your branch's commits and advance the remote branch.
git pushWhat it does
git push sends your local commits (objects your remote doesn't have) up the wire, then updates the remote's branch ref to match yours. By default it only pushes the current branch to its upstream. The remote's version of you is updated; nothing local is changed.
Your machine
local repository
Remote origin
everything.git
Your new objects travel up; the remote branch ref advances to match you
Watch it — press play
A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.
Step 1
Share your commits
You've committed locally. The remote doesn't have those objects yet — they're about to travel up.
git pushYour machine
local repository
Remote origin
everything.git
Your branch is ahead — the upload starts
Under the hood
Upload-pack negotiation, reversed
Push tells the remote what you have; the remote answers with what it still lacks; only the missing objects are sent — packed and delta-compressed.
The ref update is a claim of ancestry
Pushing branch main means: 'here are my objects, and my main is a descendant of your main.' If it's NOT (you're behind), the remote refuses with a rejected/non-fast-forward error — protecting the remote history from being orphaned.
Force-push overrides the guard
`git push --force` ignores the ancestry check. That's the forbidden-words of git: it rewrites the remote branch. Always --force-with-lease, which only forces if the remote matches what you last saw — making accidental history-wipes nearly impossible.
Tags travel separately
Branches push branches; tags need `git push --tags` (or --follow-tags) to ride along. The refspec syntax `git push origin main:feature` lets you publish your main as a different branch name on the remote.
Aliases the pros type
Memorize the git push concept, then let one of these shortcuts make it instant. Aliases are real git config keys — add one with:
git config --global alias.st # → git pushg pugit pushPush the current branch.
g pufgit push -u origin HEADFirst-time push: sets upstream and publishes in one.
g pushfgit push --force-with-leaseThe SURVIVAL push — only overwrite what you saw.
g pdgit push origin --deleteDelete a remote branch from the terminal.
Command anatomy
-uSet upstream — link local branch to remote one for future pulls/pushes.
--force-with-leaseForce the update only if the remote matches what you last fetched.
--tagsPush all tags along with branches.
--delete <b>Delete a branch on the remote.
When to reach for it
Publishing a feature branch for a PR: git push -u origin feature/x.
Sharing your newest local commits with the team after pulling and rebasing clean.
Cleaning up a merged remote branch: git push origin --delete feature/x.
Pro tip
Rejected upstream? You tried to fast-forward nothing — the remote is ahead. `git pull --rebase` first, then push. That two-step rhythm (pull --rebase, push) is the daily heartbeat of collaborative branches, and it never force-pushes by accident.