Skip to content
Latchkey

git push: Usage, Options & Common CI Errors

git push sends your local branch commits to a remote repository.

Pushing publishes your work. Most CI push failures are auth, protected branches, or a remote that moved ahead of you.

What it does

git push updates remote refs (branches/tags) using your local commits and uploads the objects needed to complete them.

Common usage

Terminal
git push                              # to the tracked upstream
git push -u origin feature           # push + set upstream
git push origin --tags               # push all tags
git push --force-with-lease          # safer force push

Options

FlagWhat it does
-u / --set-upstreamRecord the remote branch as upstream
--force-with-leaseForce only if remote matches your last fetch
--tagsPush tags as well
--deleteDelete a remote ref
--atomicAll-or-nothing for multiple refs

Common errors in CI

! [rejected] main -> main (non-fast-forward) / "Updates were rejected because the remote contains work that you do not have locally" - fetch and rebase, then push: git pull --rebase origin main. "remote: Permission to owner/repo.git denied" means the token lacks write/contents permission. On protected branches a direct push may be blocked entirely.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →