English ▾ Topics ▾ Version 2.53.0 ▾ git-push last updated in 2.55.0

NAME

git-push - Update remote refs along with associated objects

SYNOPSIS

git push [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
	 [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-q | --quiet] [-v | --verbose]
	 [-u | --set-upstream] [-o <string> | --push-option=<string>]
	 [--[no-]signed | --signed=(true|false|if-asked)]
	 [--force-with-lease[=<refname>[:<expect>]] [--force-if-includes]]
	 [--no-verify] [<repository> [<refspec>…​]]

DESCRIPTION

Updates one or more branches, tags, or other references in a remote repository from your local repository, and sends all necessary data that isn’t already on the remote.

The simplest way to push is git push <remote> <branch>. git push origin main will push the local main branch to the main branch on the remote named origin.

The <repository> argument defaults to the upstream for the current branch, or origin if there’s no configured upstream.

To decide which branches, tags, or other refs to push, Git uses (in order of precedence):

  1. The <refspec> argument(s) (for example main in git push origin main) or the --all, --mirror, or --tags options

  2. The remote.<name>.push configuration for the repository being pushed to

  3. The push.default configuration. The default is push.default=simple, which will push to a branch with the same name as the current branch. See the CONFIGURATION section below for more on push.default.

git push may fail if you haven’t set an upstream for the current branch, depending on what push.default is set to. See the UPSTREAM BRANCHES section below for more on how to set and use upstreams.

You can make interesting things happen to a repository every time you push into it, by setting up hooks there. See documentation for git-receive-pack[1].

OPTIONS

<repository>

The "remote" repository that is the destination of a push operation. This parameter can be either a URL (see the section GIT URLS below) or the name of a remote (see the section REMOTES below).

<refspec>...

Specify what destination ref to update with what source object.

The format for a refspec is [+]<src>[:<dst>], for example main, main:other, or HEAD^:refs/heads/main.

The <src> is often the name of the local branch to push, but it can be any arbitrary "SHA-1 expression" (see gitrevisions[7]).

The <dst> determines what ref to update on the remote side. It must be the name of a branch, tag, or other ref, not an arbitrary expression.

The + is optional and does the same thing as --force.

You can write a refspec using the fully expanded form (for example refs/heads/main:refs/heads/main) which specifies the exact source and destination, or with a shorter form (for example main or main:other). Here are the rules for how refspecs are expanded, as well as various other special refspec forms:

  • <src> without a :<dst> means to update the same ref as the <src>, unless the remote.<repository>.push configuration specifies a different <dst>. For example, if main is a branch, then the refspec main expands to main:refs/heads/main.

  • If <dst> unambiguously refers to a ref on the <repository> remote, then expand it to that ref. For example, if v1.0 is a tag on the remote, then HEAD:v1.0 expands to HEAD:refs/tags/v1.0.

  • If <src> resolves to a ref starting with refs/heads/ or refs/tags/, then prepend that to <dst>. For example, if main is a branch, then