Push your current branch
If your branch already has a tracking remote, a plain `git push` is enough.
git pushRun `git status` first — it tells you how many commits ahead of origin you are.
git push sends your local commits to a remote repository, making them available to your teammates. This guide covers standard pushes, setting upstream branches, force pushing safely, and what to do when a push is rejected.
You committed your changes locally but your teammates can't see them. You run `git push` and get an error: 'rejected — non-fast-forward'. Now what?
git push is how local work becomes visible to the rest of the team. But pushing to a shared branch requires care: a rejected push usually means someone else pushed first, and you need to integrate their changes before yours will be accepted.
Common mistakes developers make with this:
Gitoryx: Gitoryx shows you whether your branch is ahead of or behind origin before you push, and warns you if a force push would overwrite remote changes.
`git push` uploads your local commits to a remote repository branch. If the remote branch has commits your local branch doesn't have, the push will be rejected until you integrate those changes.
If your branch already has a tracking remote, a plain `git push` is enough.
git pushRun `git status` first — it tells you how many commits ahead of origin you are.
When you push a brand new local branch for the first time, use `-u` to set the remote tracking branch. Future `git push` and `git pull` commands will then work without arguments.
git push -u origin feature/user-authExplicitly specify the remote and target branch name.
git push origin feature/user-auth
# Push local branch to a differently-named remote branch
git push origin feature/user-auth:feature/user-auth-v2If the remote has commits you don't have locally, your push will be rejected. You need to integrate the remote changes first.
# Error:
# ! [rejected] main -> main (non-fast-forward)
# Integrate remote changes first:
git pull --rebase origin main
# Then push again:
git pushNever use `git push --force` on a shared branch (main, develop) to resolve this — you'll overwrite your teammates' commits.

See this workflow in Gitoryx. See 'ahead/behind' status for every branch before pushing
Free downloadIf you've rewritten your own feature branch (via rebase or amend) and need to push the rewritten history, use `--force-with-lease` instead of `--force`. It refuses the push if someone else has pushed to the branch since your last fetch.
git push --force-with-lease origin feature/user-authForce-pushing is only safe on branches that only you are working on. Never force-push to shared branches.
After a branch is merged, clean it up on the remote.
git push origin --delete feature/user-auth`git push --force` on `main` or `develop` overwrites the remote history and leaves teammates with a diverged history they can't easily reconcile.
Fix: Always pull and rebase before pushing to shared branches. Use `--force-with-lease` only on your personal feature branches.
Without setting the upstream, every future `git push` on that branch requires the full `git push origin <branch>` command.
Fix: Always use `git push -u origin <branch>` the first time you push a new branch.
Once a file containing an API key or password is pushed, it's in the history — even if you delete it in a later commit.
Fix: Use `.gitignore` to exclude sensitive files before they're ever added. Rotate any credentials that were accidentally exposed.

The most common reason is 'non-fast-forward': the remote has commits your local branch doesn't have. Run `git pull --rebase` to integrate the remote changes, then push again.
`--force` overwrites the remote branch regardless of what's there. `--force-with-lease` checks that nobody else pushed to the branch after your last fetch — it's a safer option that prevents accidentally overwriting teammates' work.
Use `git push -u origin <branch-name>`. The `-u` flag sets the upstream tracking so future pushes and pulls work without arguments.
Run `git push origin --delete <branch-name>`. You can also delete it from the GitHub or GitLab web interface.
Everything in this tutorial is faster and clearer with a visual Git client. Gitoryx is free, runs natively on macOS, Windows, and Linux, and built for developers who want to move fast without breaking things.