git-push
Upload local repository content to a remote
TLDR
Send local changes in the current branch to its default remote counterpart
Send changes from a specific local branch to its remote counterpart
Send changes from a specific local branch to its remote counterpart, and set the remote one as the default push/pull target of the local one
Send changes from a specific local branch to a specific remote branch
Send changes on all local branches to their counterparts in a given remote repository
Delete a branch in a remote repository
Remove remote branches that don't have a local counterpart
Publish tags that aren't yet in the remote repository
SYNOPSIS
git push [options] [repository] [refspec…]
PARAMETERS
-a, --all
Push all refs under refs/heads
--atomic
Atomic push; all succeed or fail as one
-d, --delete
Delete refs on remote
--dry-run, -n
Dry run; show what would be pushed
-f, --force
Force push; overwrite remote refs (dangerous)
--force-with-lease
Force push if remote unchanged
--force-if-includes
Force push if tip included in extra ref
-u, --set-upstream
Set upstream for future pushes
--mirror
Mirror all refs including refs/notes
--no-verify
Bypass pre-push hooks
--porcelain
Machine-readable output
--progress
Force progress reporting
-q, --quiet
Quiet; suppress progress
--receive-pack=<program>
Program to execute on remote
--recurse-submodules=<check>
Control submodules on push
--repo=<repository>
Repository to push to
--signed, --signed-off
GPG sign push
--tags
Push all refs under refs/tags
--follow-tags
Push annotated tags reachable from refs
-v, --verbose
Verbose push output
DESCRIPTION
git push updates remote refs along with associated objects using the native network transport. It transfers local commits, trees, and blobs to the remote repository, creating or fast-forwarding remote branches accordingly.
By default, git push pushes the current branch to a matching branch with the same name on the remote (tracking branch). Specify a repository URL or remote name (e.g., origin) and refspecs (e.g., master:refs/heads/master) to control what gets pushed. Refspecs follow the format src:dst, where src is a local ref and dst is the remote ref.
Use options like -u or --set-upstream to set tracking info for future pulls/pushes. --all pushes all branches, --tags pushes tags. Dry-run with -n to preview. Force pushing (-f) overwrites remote refs but risks history divergence—prefer --force-with-lease for safety.
Common workflow: commit locally, then git push origin branch. Integrates with hooks for pre/post checks on servers. Essential for collaborative development, ensuring team members access latest changes.
CAVEATS
Force pushing (-f) can overwrite shared history; use --force-with-lease instead. Non-fast-forward pushes rejected by default on shared repos unless configured otherwise. Pushing to protected branches may fail due to server hooks.
REFSPEC FORMAT
Format: <src>:<dst>. Colon separates local and remote ref. Omit dst to delete (<src>). Use : to delete current branch. Wildcards like refs/heads/*:refs/heads/* supported.
COMMON USAGE
git push origin main (push current branch).
git push --all origin (all branches).
git push origin --delete feature (delete remote branch).
HISTORY
Introduced in Git 1.0.0 (2005) by Linus Torvalds. Evolved with safety features like --force-with-lease (v1.8.4, 2013) to prevent overwriting others' work. Atomic pushes added in v2.25 (2020). Integral to Git's distributed model.
SEE ALSO
git-fetch(1), git-pull(1), git-remote(1), git-branch(1), git-config(1)


