How to Push Commits to a Remote in Git (git push)

git push uploads your local commits to a remote repository, updating the branch there to match your local branch.

Published September 27, 2026

git push uploads your local commits to a remote repository so others can fetch them. It fails if the remote has commits you do not have.

How it works

Push sends the commits of the current branch to the matching remote branch. The first time use -u to set the upstream so future pushes need no arguments.

If the push is rejected, run git pull (or fetch and rebase) to integrate remote changes first.

Try it

git push -u origin feature-login
Branch 'feature-login' set up to track 'origin/feature-login'.
git push
Everything up-to-date

Practical examples

First push of a branch

git push -u origin feature-login

Push tags

git push --tags

Delete a remote branch

git push origin --delete old-branch

Safer force push

git push --force-with-lease

Common mistakes

  • Using --force on shared branches.
  • Pushing to the wrong remote or branch.
  • Not pulling before pushing.

Key takeaways

  • Push shares commits.
  • -u sets upstream.
  • Prefer --force-with-lease.

FAQ

Why was my push rejected?

The remote has commits you lack; pull or rebase first.

What is origin?

The default name for the remote you cloned from.

More Git articles