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 pushOptions
| Flag | What it does |
|---|---|
| -u / --set-upstream | Record the remote branch as upstream |
| --force-with-lease | Force only if remote matches your last fetch |
| --tags | Push tags as well |
| --delete | Delete a remote ref |
| --atomic | All-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
git pull: Usage, Options & Common CI Errorsgit pull fetches from a remote and integrates the changes. Reference for --rebase, --ff-only, and the merge-c…
git fetch: Usage, Options & Common CI Errorsgit fetch downloads remote objects and refs without touching your working tree. Reference for --depth, --unsh…
git remote: Usage, Options & Common CI Errorsgit remote manages the named connections to remote repositories. Reference for add, set-url, -v, remove, and…
Git "Host key verification failed" in CI - Fix known_hostsFix Git "Host key verification failed" in CI - the Git host is not in known_hosts, so SSH aborts before authe…