Home Explore Blog CI



git

9th chunk of `Documentation/git-push.adoc`
a154a9a3b0029f9009ef72371d69e9cbaa1aa1fcadf2096700000001000008e1
 into a repository nobody else pushes into. After you push commit
A yourself (in the first picture in this section), replace it with "git
commit --amend" to produce commit B, and you try to push it out, because
forgot that you have pushed A out already. In such a case, and only if
you are certain that nobody in the meantime fetched your earlier commit A
(and started building on top of it), you can run "git push --force" to
overwrite it. In other words, "git push --force" is a method reserved for
a case where you do mean to lose history.


EXAMPLES
--------

`git push`::
	Works like `git push <remote>`, where <remote> is the
	current branch's remote (or `origin`, if no remote is
	configured for the current branch).

`git push origin`::
	Without additional configuration, pushes the current branch to
	the configured upstream (`branch.<name>.merge` configuration
	variable) if it has the same name as the current branch, and
	errors out without pushing otherwise.
+
The default behavior of this command when no <refspec> is given can be
configured by setting the `push` option of the remote, or the `push.default`
configuration variable.
+
For example, to default to pushing only the current branch to `origin`
use `git config remote.origin.push HEAD`.  Any valid <refspec> (like
the ones in the examples below) can be configured as the default for
`git push origin`.

`git push origin :`::
	Push "matching" branches to `origin`. See
	<refspec> in the <<OPTIONS,OPTIONS>> section above for a
	description of "matching" branches.

`git push origin master`::
	Find a ref that matches `master` in the source repository
	(most likely, it would find `refs/heads/master`), and update
	the same ref (e.g. `refs/heads/master`) in `origin` repository
	with it.  If `master` did not exist remotely, it would be
	created.

`git push origin HEAD`::
	A handy way to push the current branch to the same name on the
	remote.

`git push mothership master:satellite/master dev:satellite/dev`::
	Use the source ref that matches `master` (e.g. `refs/heads/master`)
	to update the ref that matches `satellite/master` (most probably
	`refs/remotes/satellite/master`) in the `mothership` repository;
	do the same for `dev` and `satellite/dev`.
+
See the section describing `<refspec>...`

Title: Git Push Command Examples and Configuration
Summary
The git push command can be used in various ways, including pushing the current branch to a remote repository, pushing a specific branch, or using refspecs to update multiple branches, and its default behavior can be configured using options like `push.default` or `remote.origin.push`