2005-09-08 02:26:23 +02:00
|
|
|
git-push(1)
|
|
|
|
===========
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
NAME
|
|
|
|
----
|
2006-03-09 17:24:50 +01:00
|
|
|
git-push - Update remote refs along with associated objects
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
SYNOPSIS
|
|
|
|
--------
|
2007-05-18 15:39:34 +02:00
|
|
|
[verse]
|
2013-03-04 21:09:50 +01:00
|
|
|
'git push' [--all | --mirror | --tags] [--follow-tags] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
|
push: the beginning of "git push --signed"
While signed tags and commits assert that the objects thusly signed
came from you, who signed these objects, there is not a good way to
assert that you wanted to have a particular object at the tip of a
particular branch. My signing v2.0.1 tag only means I want to call
the version v2.0.1, and it does not mean I want to push it out to my
'master' branch---it is likely that I only want it in 'maint', so
the signature on the object alone is insufficient.
The only assurance to you that 'maint' points at what I wanted to
place there comes from your trust on the hosting site and my
authentication with it, which cannot easily audited later.
Introduce a mechanism that allows you to sign a "push certificate"
(for the lack of better name) every time you push, asserting that
what object you are pushing to update which ref that used to point
at what other object. Think of it as a cryptographic protection for
ref updates, similar to signed tags/commits but working on an
orthogonal axis.
The basic flow based on this mechanism goes like this:
1. You push out your work with "git push --signed".
2. The sending side learns where the remote refs are as usual,
together with what protocol extension the receiving end
supports. If the receiving end does not advertise the protocol
extension "push-cert", an attempt to "git push --signed" fails.
Otherwise, a text file, that looks like the following, is
prepared in core:
certificate version 0.1
pusher Junio C Hamano <gitster@pobox.com> 1315427886 -0700
7339ca65... 21580ecb... refs/heads/master
3793ac56... 12850bec... refs/heads/next
The file begins with a few header lines, which may grow as we
gain more experience. The 'pusher' header records the name of
the signer (the value of user.signingkey configuration variable,
falling back to GIT_COMMITTER_{NAME|EMAIL}) and the time of the
certificate generation. After the header, a blank line follows,
followed by a copy of the protocol message lines.
Each line shows the old and the new object name at the tip of
the ref this push tries to update, in the way identical to how
the underlying "git push" protocol exchange tells the ref
updates to the receiving end (by recording the "old" object
name, the push certificate also protects against replaying). It
is expected that new command packet types other than the
old-new-refname kind will be included in push certificate in the
same way as would appear in the plain vanilla command packets in
unsigned pushes.
The user then is asked to sign this push certificate using GPG,
formatted in a way similar to how signed tag objects are signed,
and the result is sent to the other side (i.e. receive-pack).
In the protocol exchange, this step comes immediately before the
sender tells what the result of the push should be, which in
turn comes before it sends the pack data.
3. When the receiving end sees a push certificate, the certificate
is written out as a blob. The pre-receive hook can learn about
the certificate by checking GIT_PUSH_CERT environment variable,
which, if present, tells the object name of this blob, and make
the decision to allow or reject this push. Additionally, the
post-receive hook can also look at the certificate, which may be
a good place to log all the received certificates for later
audits.
Because a push certificate carry the same information as the usual
command packets in the protocol exchange, we can omit the latter
when a push certificate is in use and reduce the protocol overhead.
This however is not included in this patch to make it easier to
review (in other words, the series at this step should never be
released without the remainder of the series, as it implements an
interim protocol that will be incompatible with the final one).
As such, the documentation update for the protocol is left out of
this step.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-12 20:17:07 +02:00
|
|
|
[--repo=<repository>] [-f | --force] [--prune] [-v | --verbose]
|
|
|
|
[-u | --set-upstream] [--signed]
|
remote.c: add command line option parser for "--force-with-lease"
Update "git push" and "git send-pack" to parse this commnd line
option.
The intended sematics is:
* "--force-with-lease" alone, without specifying the details, will
protect _all_ remote refs that are going to be updated by
requiring their current value to be the same as some reasonable
default, unless otherwise specified;
* "--force-with-lease=refname", without specifying the expected
value, will protect that refname, if it is going to be updated,
by requiring its current value to be the same as some reasonable
default.
* "--force-with-lease=refname:value" will protect that refname, if
it is going to be updated, by requiring its current value to be
the same as the specified value; and
* "--no-force-with-lease" will cancel all the previous --force-with-lease on the
command line.
For now, "some reasonable default" is tentatively defined as "the
value of the remote-tracking branch we have for the ref of the
remote being updated", and it is an error if we do not have such a
remote-tracking branch. But this is known to be fragile, its use is
not yet recommended, and hopefully we will find more reasonable
default as we gain experience with this feature. The manual marks
the feature as experimental unless the expected value is specified
explicitly for this reason.
Because the command line options are parsed _before_ we know which
remote we are pushing to, there needs further processing to the
parsed data after we instantiate the transport object to:
* expand "refname" given by the user to a full refname to be
matched with the list of "struct ref" used in match_push_refs()
and set_ref_status_for_push(); and
* learning the actual local ref that is the remote-tracking branch
for the specified remote ref.
Further, some processing need to be deferred until we find the set
of remote refs and match_push_refs() returns in order to find the
ones that need to be checked after explicit ones have been processed
for "--force-with-lease" (no specific details).
These post-processing will be the topic of the next patch.
This option was originally called "cas" (for "compare and swap"),
the name which nobody liked because it was too technical. The
second attempt called it "lockref" (because it is conceptually like
pushing after taking a lock) but the word "lock" was hated because
it implied that it may reject push by others, which is not the way
this option works. This round calls it "force-with-lease". You
assume you took the lease on the ref when you fetched to decide what
the rebased history should be, and you can push back only if the
lease has not been broken.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-09 00:34:36 +02:00
|
|
|
[--force-with-lease[=<refname>[:<expect>]]]
|
2013-05-23 15:34:11 +02:00
|
|
|
[--no-verify] [<repository> [<refspec>...]]
|
2005-08-23 10:49:47 +02:00
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
-----------
|
2005-08-25 01:23:08 +02:00
|
|
|
|
|
|
|
Updates remote refs using local refs, while sending objects
|
|
|
|
necessary to complete the given refs.
|
2005-08-23 10:49:47 +02:00
|
|
|
|
2006-02-06 01:42:27 +01:00
|
|
|
You can make interesting things happen to a repository
|
2005-12-05 09:32:01 +01:00
|
|
|
every time you push into it, by setting up 'hooks' there. See
|
2007-12-29 07:20:38 +01:00
|
|
|
documentation for linkgit:git-receive-pack[1].
|
2005-12-05 09:32:01 +01:00
|
|
|
|
2013-03-08 18:44:33 +01:00
|
|
|
When the command line does not specify where to push with the
|
|
|
|
`<repository>` argument, `branch.*.remote` configuration for the
|
|
|
|
current branch is consulted to determine where to push. If the
|
|
|
|
configuration is missing, it defaults to 'origin'.
|
|
|
|
|
|
|
|
When the command line does not specify what to push with `<refspec>...`
|
|
|
|
arguments or `--all`, `--mirror`, `--tags` options, the command finds
|
|
|
|
the default `<refspec>` by consulting `remote.*.push` configuration,
|
|
|
|
and if it is not found, honors `push.default` configuration to decide
|
2014-11-17 01:49:00 +01:00
|
|
|
what to push (See linkgit:git-config[1] for the meaning of `push.default`).
|
2013-03-08 18:44:33 +01:00
|
|
|
|
2005-08-23 10:49:47 +02:00
|
|
|
|
2009-03-15 03:32:01 +01:00
|
|
|
OPTIONS[[OPTIONS]]
|
|
|
|
------------------
|
2006-02-05 23:43:47 +01:00
|
|
|
<repository>::
|
2006-02-06 00:29:49 +01:00
|
|
|
The "remote" repository that is destination of a push
|
2009-01-18 15:36:55 +01:00
|
|
|
operation. This parameter can be either a URL
|
|
|
|
(see the section <<URLS,GIT URLS>> below) or the name
|
|
|
|
of a remote (see the section <<REMOTES,REMOTES>> below).
|
2006-02-05 23:43:47 +01:00
|
|
|
|
2008-07-30 01:13:38 +02:00
|
|
|
<refspec>...::
|
2013-03-08 18:44:33 +01:00
|
|
|
Specify what destination ref to update with what source object.
|
2009-01-26 07:25:20 +01:00
|
|
|
The format of a <refspec> parameter is an optional plus
|
2013-03-08 18:44:33 +01:00
|
|
|
`+`, followed by the source object <src>, followed
|
2009-01-26 07:25:20 +01:00
|
|
|
by a colon `:`, followed by the destination ref <dst>.
|
2006-02-05 23:43:47 +01:00
|
|
|
+
|
2009-01-26 00:45:33 +01:00
|
|
|
The <src> is often the name of the branch you would want to push, but
|
|
|
|
it can be any arbitrary "SHA-1 expression", such as `master~4` or
|
2010-10-11 18:03:32 +02:00
|
|
|
`HEAD` (see linkgit:gitrevisions[7]).
|
2006-02-05 23:43:47 +01:00
|
|
|
+
|
2009-01-26 00:45:33 +01:00
|
|
|
The <dst> tells which ref on the remote side is updated with this
|
|
|
|
push. Arbitrary expressions cannot be used here, an actual ref must
|
push: use remote.$name.push as a refmap
Since f2690487 (fetch: opportunistically update tracking refs,
2013-05-11), we stopped taking a non-storing refspec given on the
command line of "git fetch" literally, and instead started mapping
it via remote.$name.fetch refspecs. This allows
$ git fetch origin master
from the 'origin' repository, which is configured with
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
to update refs/remotes/origin/master with the result, as if the
command line were
$ git fetch origin +master:refs/remotes/origin/master
to reduce surprises and improve usability. Before that change, a
refspec on the command line without a colon was only to fetch the
history and leave the result in FETCH_HEAD, without updating the
remote-tracking branches.
When you are simulating a fetch from you by your mothership with a
push by you into your mothership, instead of having:
[remote "satellite"]
fetch = +refs/heads/*:refs/remotes/satellite/*
on the mothership repository and running:
mothership$ git fetch satellite
you would have:
[remote "mothership"]
push = +refs/heads/*:refs/remotes/satellite/*
on your satellite machine, and run:
satellite$ git push mothership
Because we so far did not make the corresponding change to the push
side, this command:
satellite$ git push mothership master
does _not_ allow you on the satellite to only push 'master' out but
still to the usual destination (i.e. refs/remotes/satellite/master).
Implement the logic to map an unqualified refspec given on the
command line via the remote.$name.push refspec. This will bring a
bit more symmetry between "fetch" and "push".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-04 00:41:15 +01:00
|
|
|
be named.
|
|
|
|
If `git push [<repository>]` without any `<refspec>` argument is set to
|
|
|
|
update some ref at the destination with `<src>` with
|
|
|
|
`remote.<repository>.push` configuration variable, `:<dst>` part can
|
|
|
|
be omitted---such a push will update a ref that `<src>` normally updates
|
|
|
|
without any `<refspec>` on the command line. Otherwise, missing
|
|
|
|
`:<dst>` means to update the same ref as the `<src>`.
|
2006-02-05 23:43:47 +01:00
|
|
|
+
|
2009-02-19 18:39:47 +01:00
|
|
|
The object referenced by <src> is used to update the <dst> reference
|
2012-11-30 02:41:37 +01:00
|
|
|
on the remote side. By default this is only allowed if <dst> is not
|
2012-11-30 02:41:38 +01:00
|
|
|
a tag (annotated or lightweight), and then only if it can fast-forward
|
2013-01-21 20:17:53 +01:00
|
|
|
<dst>. By having the optional leading `+`, you can tell Git to update
|
2012-11-30 02:41:38 +01:00
|
|
|
the <dst> ref even if it is not allowed by default (e.g., it is not a
|
|
|
|
fast-forward.) This does *not* attempt to merge <src> into <dst>. See
|
2009-02-19 18:39:47 +01:00
|
|
|
EXAMPLES below for details.
|
2006-02-05 23:43:47 +01:00
|
|
|
+
|
2009-01-26 00:45:33 +01:00
|
|
|
`tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
|
2006-12-13 09:59:58 +01:00
|
|
|
+
|
|
|
|
Pushing an empty <src> allows you to delete the <dst> ref from
|
|
|
|
the remote repository.
|
2008-04-28 17:32:12 +02:00
|
|
|
+
|
docs: stop using asciidoc no-inline-literal
In asciidoc 7, backticks like `foo` produced a typographic
effect, but did not otherwise affect the syntax. In asciidoc
8, backticks introduce an "inline literal" inside which markup
is not interpreted. To keep compatibility with existing
documents, asciidoc 8 has a "no-inline-literal" attribute to
keep the old behavior. We enabled this so that the
documentation could be built on either version.
It has been several years now, and asciidoc 7 is no longer
in wide use. We can now decide whether or not we want
inline literals on their own merits, which are:
1. The source is much easier to read when the literal
contains punctuation. You can use `master~1` instead
of `master{tilde}1`.
2. They are less error-prone. Because of point (1), we
tend to make mistakes and forget the extra layer of
quoting.
This patch removes the no-inline-literal attribute from the
Makefile and converts every use of backticks in the
documentation to an inline literal (they must be cleaned up,
or the example above would literally show "{tilde}" in the
output).
Problematic sites were found by grepping for '`.*[{\\]' and
examined and fixed manually. The results were then verified
by comparing the output of "html2text" on the set of
generated html pages. Doing so revealed that in addition to
making the source more readable, this patch fixes several
formatting bugs:
- HTML rendering used the ellipsis character instead of
literal "..." in code examples (like "git log A...B")
- some code examples used the right-arrow character
instead of '->' because they failed to quote
- api-config.txt did not quote tilde, and the resulting
HTML contained a bogus snippet like:
<tt><sub></tt> foo <tt></sub>bar</tt>
which caused some parsers to choke and omit whole
sections of the page.
- git-commit.txt confused ``foo`` (backticks inside a
literal) with ``foo'' (matched double-quotes)
- mentions of `A U Thor <author@example.com>` used to
erroneously auto-generate a mailto footnote for
author@example.com
- the description of --word-diff=plain incorrectly showed
the output as "[-removed-] and {added}", not "{+added+}".
- using "prime" notation like:
commit `C` and its replacement `C'`
confused asciidoc into thinking that everything between
the first backtick and the final apostrophe were meant
to be inside matched quotes
- asciidoc got confused by the escaping of some of our
asterisks. In particular,
`credential.\*` and `credential.<url>.\*`
properly escaped the asterisk in the first case, but
literally passed through the backslash in the second
case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26 10:51:57 +02:00
|
|
|
The special refspec `:` (or `+:` to allow non-fast-forward updates)
|
2013-01-21 20:17:53 +01:00
|
|
|
directs Git to push "matching" branches: for every branch that exists on
|
2009-01-18 15:36:57 +01:00
|
|
|
the local side, the remote side is updated if a branch of the same name
|
2013-03-08 18:44:33 +01:00
|
|
|
already exists on the remote side.
|
2005-08-23 10:49:47 +02:00
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
--all::
|
2013-01-05 01:02:29 +01:00
|
|
|
Push all branches (i.e. refs under `refs/heads/`); cannot be
|
|
|
|
used with other <refspec>.
|
2005-10-20 06:25:39 +02:00
|
|
|
|
2012-02-22 23:43:41 +01:00
|
|
|
--prune::
|
|
|
|
Remove remote branches that don't have a local counterpart. For example
|
|
|
|
a remote branch `tmp` will be removed if a local branch with the same
|
|
|
|
name doesn't exist any more. This also respects refspecs, e.g.
|
docs: stop using asciidoc no-inline-literal
In asciidoc 7, backticks like `foo` produced a typographic
effect, but did not otherwise affect the syntax. In asciidoc
8, backticks introduce an "inline literal" inside which markup
is not interpreted. To keep compatibility with existing
documents, asciidoc 8 has a "no-inline-literal" attribute to
keep the old behavior. We enabled this so that the
documentation could be built on either version.
It has been several years now, and asciidoc 7 is no longer
in wide use. We can now decide whether or not we want
inline literals on their own merits, which are:
1. The source is much easier to read when the literal
contains punctuation. You can use `master~1` instead
of `master{tilde}1`.
2. They are less error-prone. Because of point (1), we
tend to make mistakes and forget the extra layer of
quoting.
This patch removes the no-inline-literal attribute from the
Makefile and converts every use of backticks in the
documentation to an inline literal (they must be cleaned up,
or the example above would literally show "{tilde}" in the
output).
Problematic sites were found by grepping for '`.*[{\\]' and
examined and fixed manually. The results were then verified
by comparing the output of "html2text" on the set of
generated html pages. Doing so revealed that in addition to
making the source more readable, this patch fixes several
formatting bugs:
- HTML rendering used the ellipsis character instead of
literal "..." in code examples (like "git log A...B")
- some code examples used the right-arrow character
instead of '->' because they failed to quote
- api-config.txt did not quote tilde, and the resulting
HTML contained a bogus snippet like:
<tt><sub></tt> foo <tt></sub>bar</tt>
which caused some parsers to choke and omit whole
sections of the page.
- git-commit.txt confused ``foo`` (backticks inside a
literal) with ``foo'' (matched double-quotes)
- mentions of `A U Thor <author@example.com>` used to
erroneously auto-generate a mailto footnote for
author@example.com
- the description of --word-diff=plain incorrectly showed
the output as "[-removed-] and {added}", not "{+added+}".
- using "prime" notation like:
commit `C` and its replacement `C'`
confused asciidoc into thinking that everything between
the first backtick and the final apostrophe were meant
to be inside matched quotes
- asciidoc got confused by the escaping of some of our
asterisks. In particular,
`credential.\*` and `credential.<url>.\*`
properly escaped the asterisk in the first case, but
literally passed through the backslash in the second
case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26 10:51:57 +02:00
|
|
|
`git push --prune remote refs/heads/*:refs/tmp/*` would
|
2012-02-22 23:43:41 +01:00
|
|
|
make sure that remote `refs/tmp/foo` will be removed if `refs/heads/foo`
|
|
|
|
doesn't exist.
|
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
--mirror::
|
2007-11-10 00:32:57 +01:00
|
|
|
Instead of naming each ref to push, specifies that all
|
docs: don't talk about $GIT_DIR/refs/ everywhere
It is misleading to say that we pull refs from $GIT_DIR/refs/*, because we
may also consult the packed refs mechanism. These days we tend to treat
the "refs hierarchy" as more of an abstract namespace that happens to be
represented as $GIT_DIR/refs. At best, this is a minor inaccuracy, but at
worst it can confuse users who then look in $GIT_DIR/refs and find that it
is missing some of the refs they expected to see.
This patch drops most uses of "$GIT_DIR/refs/*", changing them into just
"refs/*", under the assumption that users can handle the concept of an
abstract refs namespace. There are a few things to note:
- most cases just dropped the $GIT_DIR/ portion. But for cases where
that left _just_ the word "refs", I changed it to "refs/" to help
indicate that it was a hierarchy. I didn't do the same for longer
paths (e.g., "refs/heads" remained, instead of becoming
"refs/heads/").
- in some cases, no change was made, as the text was explicitly about
unpacked refs (e.g., the discussion in git-pack-refs).
- In some cases it made sense instead to note the existence of packed
refs (e.g., in check-ref-format and rev-parse).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-18 02:16:20 +01:00
|
|
|
refs under `refs/` (which includes but is not
|
2008-06-21 05:25:25 +02:00
|
|
|
limited to `refs/heads/`, `refs/remotes/`, and `refs/tags/`)
|
2007-11-10 00:32:57 +01:00
|
|
|
be mirrored to the remote repository. Newly created local
|
|
|
|
refs will be pushed to the remote end, locally updated refs
|
|
|
|
will be force updated on the remote end, and deleted refs
|
2008-04-17 13:17:20 +02:00
|
|
|
will be removed from the remote end. This is the default
|
|
|
|
if the configuration option `remote.<remote>.mirror` is
|
|
|
|
set.
|
2007-11-10 00:32:57 +01:00
|
|
|
|
2009-09-13 18:56:45 +02:00
|
|
|
-n::
|
2008-06-08 03:36:09 +02:00
|
|
|
--dry-run::
|
2007-10-11 21:32:27 +02:00
|
|
|
Do everything except actually send the updates.
|
|
|
|
|
2009-06-23 03:10:01 +02:00
|
|
|
--porcelain::
|
|
|
|
Produce machine-readable output. The output status line for each ref
|
|
|
|
will be tab-separated and sent to stdout instead of stderr. The full
|
|
|
|
symbolic names of the refs will be given.
|
|
|
|
|
2009-12-30 20:57:42 +01:00
|
|
|
--delete::
|
|
|
|
All listed refs are deleted from the remote repository. This is
|
|
|
|
the same as prefixing all refs with a colon.
|
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
--tags::
|
docs: don't talk about $GIT_DIR/refs/ everywhere
It is misleading to say that we pull refs from $GIT_DIR/refs/*, because we
may also consult the packed refs mechanism. These days we tend to treat
the "refs hierarchy" as more of an abstract namespace that happens to be
represented as $GIT_DIR/refs. At best, this is a minor inaccuracy, but at
worst it can confuse users who then look in $GIT_DIR/refs and find that it
is missing some of the refs they expected to see.
This patch drops most uses of "$GIT_DIR/refs/*", changing them into just
"refs/*", under the assumption that users can handle the concept of an
abstract refs namespace. There are a few things to note:
- most cases just dropped the $GIT_DIR/ portion. But for cases where
that left _just_ the word "refs", I changed it to "refs/" to help
indicate that it was a hierarchy. I didn't do the same for longer
paths (e.g., "refs/heads" remained, instead of becoming
"refs/heads/").
- in some cases, no change was made, as the text was explicitly about
unpacked refs (e.g., the discussion in git-pack-refs).
- In some cases it made sense instead to note the existence of packed
refs (e.g., in check-ref-format and rev-parse).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-02-18 02:16:20 +01:00
|
|
|
All refs under `refs/tags` are pushed, in
|
2006-01-16 08:27:34 +01:00
|
|
|
addition to refspecs explicitly listed on the command
|
|
|
|
line.
|
|
|
|
|
2013-03-04 21:09:50 +01:00
|
|
|
--follow-tags::
|
|
|
|
Push all the refs that would be pushed without this option,
|
|
|
|
and also push annotated tags in `refs/tags` that are missing
|
2013-09-04 21:04:31 +02:00
|
|
|
from the remote but are pointing at commit-ish that are
|
2013-03-04 21:09:50 +01:00
|
|
|
reachable from the refs being pushed.
|
|
|
|
|
push: the beginning of "git push --signed"
While signed tags and commits assert that the objects thusly signed
came from you, who signed these objects, there is not a good way to
assert that you wanted to have a particular object at the tip of a
particular branch. My signing v2.0.1 tag only means I want to call
the version v2.0.1, and it does not mean I want to push it out to my
'master' branch---it is likely that I only want it in 'maint', so
the signature on the object alone is insufficient.
The only assurance to you that 'maint' points at what I wanted to
place there comes from your trust on the hosting site and my
authentication with it, which cannot easily audited later.
Introduce a mechanism that allows you to sign a "push certificate"
(for the lack of better name) every time you push, asserting that
what object you are pushing to update which ref that used to point
at what other object. Think of it as a cryptographic protection for
ref updates, similar to signed tags/commits but working on an
orthogonal axis.
The basic flow based on this mechanism goes like this:
1. You push out your work with "git push --signed".
2. The sending side learns where the remote refs are as usual,
together with what protocol extension the receiving end
supports. If the receiving end does not advertise the protocol
extension "push-cert", an attempt to "git push --signed" fails.
Otherwise, a text file, that looks like the following, is
prepared in core:
certificate version 0.1
pusher Junio C Hamano <gitster@pobox.com> 1315427886 -0700
7339ca65... 21580ecb... refs/heads/master
3793ac56... 12850bec... refs/heads/next
The file begins with a few header lines, which may grow as we
gain more experience. The 'pusher' header records the name of
the signer (the value of user.signingkey configuration variable,
falling back to GIT_COMMITTER_{NAME|EMAIL}) and the time of the
certificate generation. After the header, a blank line follows,
followed by a copy of the protocol message lines.
Each line shows the old and the new object name at the tip of
the ref this push tries to update, in the way identical to how
the underlying "git push" protocol exchange tells the ref
updates to the receiving end (by recording the "old" object
name, the push certificate also protects against replaying). It
is expected that new command packet types other than the
old-new-refname kind will be included in push certificate in the
same way as would appear in the plain vanilla command packets in
unsigned pushes.
The user then is asked to sign this push certificate using GPG,
formatted in a way similar to how signed tag objects are signed,
and the result is sent to the other side (i.e. receive-pack).
In the protocol exchange, this step comes immediately before the
sender tells what the result of the push should be, which in
turn comes before it sends the pack data.
3. When the receiving end sees a push certificate, the certificate
is written out as a blob. The pre-receive hook can learn about
the certificate by checking GIT_PUSH_CERT environment variable,
which, if present, tells the object name of this blob, and make
the decision to allow or reject this push. Additionally, the
post-receive hook can also look at the certificate, which may be
a good place to log all the received certificates for later
audits.
Because a push certificate carry the same information as the usual
command packets in the protocol exchange, we can omit the latter
when a push certificate is in use and reduce the protocol overhead.
This however is not included in this patch to make it easier to
review (in other words, the series at this step should never be
released without the remainder of the series, as it implements an
interim protocol that will be incompatible with the final one).
As such, the documentation update for the protocol is left out of
this step.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-09-12 20:17:07 +02:00
|
|
|
--signed::
|
|
|
|
GPG-sign the push request to update refs on the receiving
|
|
|
|
side, to allow it to be checked by the hooks and/or be
|
|
|
|
logged. See linkgit:git-receive-pack[1] for the details
|
|
|
|
on the receiving end.
|
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
--receive-pack=<git-receive-pack>::
|
2009-01-12 04:05:54 +01:00
|
|
|
--exec=<git-receive-pack>::
|
2008-07-03 07:41:41 +02:00
|
|
|
Path to the 'git-receive-pack' program on the remote
|
2007-01-16 16:02:02 +01:00
|
|
|
end. Sometimes useful when pushing to a remote
|
|
|
|
repository over ssh, and you do not have the program in
|
|
|
|
a directory on the default $PATH.
|
|
|
|
|
remote.c: add command line option parser for "--force-with-lease"
Update "git push" and "git send-pack" to parse this commnd line
option.
The intended sematics is:
* "--force-with-lease" alone, without specifying the details, will
protect _all_ remote refs that are going to be updated by
requiring their current value to be the same as some reasonable
default, unless otherwise specified;
* "--force-with-lease=refname", without specifying the expected
value, will protect that refname, if it is going to be updated,
by requiring its current value to be the same as some reasonable
default.
* "--force-with-lease=refname:value" will protect that refname, if
it is going to be updated, by requiring its current value to be
the same as the specified value; and
* "--no-force-with-lease" will cancel all the previous --force-with-lease on the
command line.
For now, "some reasonable default" is tentatively defined as "the
value of the remote-tracking branch we have for the ref of the
remote being updated", and it is an error if we do not have such a
remote-tracking branch. But this is known to be fragile, its use is
not yet recommended, and hopefully we will find more reasonable
default as we gain experience with this feature. The manual marks
the feature as experimental unless the expected value is specified
explicitly for this reason.
Because the command line options are parsed _before_ we know which
remote we are pushing to, there needs further processing to the
parsed data after we instantiate the transport object to:
* expand "refname" given by the user to a full refname to be
matched with the list of "struct ref" used in match_push_refs()
and set_ref_status_for_push(); and
* learning the actual local ref that is the remote-tracking branch
for the specified remote ref.
Further, some processing need to be deferred until we find the set
of remote refs and match_push_refs() returns in order to find the
ones that need to be checked after explicit ones have been processed
for "--force-with-lease" (no specific details).
These post-processing will be the topic of the next patch.
This option was originally called "cas" (for "compare and swap"),
the name which nobody liked because it was too technical. The
second attempt called it "lockref" (because it is conceptually like
pushing after taking a lock) but the word "lock" was hated because
it implied that it may reject push by others, which is not the way
this option works. This round calls it "force-with-lease". You
assume you took the lease on the ref when you fetched to decide what
the rebased history should be, and you can push back only if the
lease has not been broken.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-09 00:34:36 +02:00
|
|
|
--[no-]force-with-lease::
|
|
|
|
--force-with-lease=<refname>::
|
|
|
|
--force-with-lease=<refname>:<expect>::
|
|
|
|
Usually, "git push" refuses to update a remote ref that is
|
|
|
|
not an ancestor of the local ref used to overwrite it.
|
|
|
|
+
|
|
|
|
This option bypasses the check, but instead requires that the
|
|
|
|
current value of the ref to be the expected value. "git push"
|
|
|
|
fails otherwise.
|
|
|
|
+
|
|
|
|
Imagine that you have to rebase what you have already published.
|
|
|
|
You will have to bypass the "must fast-forward" rule in order to
|
|
|
|
replace the history you originally published with the rebased history.
|
|
|
|
If somebody else built on top of your original history while you are
|
|
|
|
rebasing, the tip of the branch at the remote may advance with her
|
|
|
|
commit, and blindly pushing with `--force` will lose her work.
|
|
|
|
+
|
|
|
|
This option allows you to say that you expect the history you are
|
|
|
|
updating is what you rebased and want to replace. If the remote ref
|
|
|
|
still points at the commit you specified, you can be sure that no
|
|
|
|
other people did anything to the ref (it is like taking a "lease" on
|
|
|
|
the ref without explicitly locking it, and you update the ref while
|
|
|
|
making sure that your earlier "lease" is still valid).
|
|
|
|
+
|
|
|
|
`--force-with-lease` alone, without specifying the details, will protect
|
|
|
|
all remote refs that are going to be updated by requiring their
|
|
|
|
current value to be the same as the remote-tracking branch we have
|
|
|
|
for them, unless specified with a `--force-with-lease=<refname>:<expect>`
|
|
|
|
option that explicitly states what the expected value is.
|
|
|
|
+
|
|
|
|
`--force-with-lease=<refname>`, without specifying the expected value, will
|
|
|
|
protect the named ref (alone), if it is going to be updated, by
|
|
|
|
requiring its current value to be the same as the remote-tracking
|
|
|
|
branch we have for it.
|
|
|
|
+
|
|
|
|
`--force-with-lease=<refname>:<expect>` will protect the named ref (alone),
|
|
|
|
if it is going to be updated, by requiring its current value to be
|
|
|
|
the same as the specified value <expect> (which is allowed to be
|
|
|
|
different from the remote-tracking branch we have for the refname,
|
|
|
|
or we do not even have to have such a remote-tracking branch when
|
|
|
|
this form is used).
|
|
|
|
+
|
|
|
|
Note that all forms other than `--force-with-lease=<refname>:<expect>`
|
|
|
|
that specifies the expected current value of the ref explicitly are
|
|
|
|
still experimental and their semantics may change as we gain experience
|
|
|
|
with this feature.
|
|
|
|
+
|
|
|
|
"--no-force-with-lease" will cancel all the previous --force-with-lease on the
|
|
|
|
command line.
|
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
-f::
|
|
|
|
--force::
|
2006-01-30 02:40:50 +01:00
|
|
|
Usually, the command refuses to update a remote ref that is
|
2007-08-05 07:22:15 +02:00
|
|
|
not an ancestor of the local ref used to overwrite it.
|
remote.c: add command line option parser for "--force-with-lease"
Update "git push" and "git send-pack" to parse this commnd line
option.
The intended sematics is:
* "--force-with-lease" alone, without specifying the details, will
protect _all_ remote refs that are going to be updated by
requiring their current value to be the same as some reasonable
default, unless otherwise specified;
* "--force-with-lease=refname", without specifying the expected
value, will protect that refname, if it is going to be updated,
by requiring its current value to be the same as some reasonable
default.
* "--force-with-lease=refname:value" will protect that refname, if
it is going to be updated, by requiring its current value to be
the same as the specified value; and
* "--no-force-with-lease" will cancel all the previous --force-with-lease on the
command line.
For now, "some reasonable default" is tentatively defined as "the
value of the remote-tracking branch we have for the ref of the
remote being updated", and it is an error if we do not have such a
remote-tracking branch. But this is known to be fragile, its use is
not yet recommended, and hopefully we will find more reasonable
default as we gain experience with this feature. The manual marks
the feature as experimental unless the expected value is specified
explicitly for this reason.
Because the command line options are parsed _before_ we know which
remote we are pushing to, there needs further processing to the
parsed data after we instantiate the transport object to:
* expand "refname" given by the user to a full refname to be
matched with the list of "struct ref" used in match_push_refs()
and set_ref_status_for_push(); and
* learning the actual local ref that is the remote-tracking branch
for the specified remote ref.
Further, some processing need to be deferred until we find the set
of remote refs and match_push_refs() returns in order to find the
ones that need to be checked after explicit ones have been processed
for "--force-with-lease" (no specific details).
These post-processing will be the topic of the next patch.
This option was originally called "cas" (for "compare and swap"),
the name which nobody liked because it was too technical. The
second attempt called it "lockref" (because it is conceptually like
pushing after taking a lock) but the word "lock" was hated because
it implied that it may reject push by others, which is not the way
this option works. This round calls it "force-with-lease". You
assume you took the lease on the ref when you fetched to decide what
the rebased history should be, and you can push back only if the
lease has not been broken.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-09 00:34:36 +02:00
|
|
|
Also, when `--force-with-lease` option is used, the command refuses
|
|
|
|
to update a remote ref whose current value does not match
|
|
|
|
what is expected.
|
|
|
|
+
|
|
|
|
This flag disables these checks, and can cause the remote repository
|
|
|
|
to lose commits; use it with care.
|
|
|
|
+
|
|
|
|
Note that `--force` applies to all the refs that are pushed, hence
|
|
|
|
using it with `push.default` set to `matching` or with multiple push
|
|
|
|
destinations configured with `remote.*.push` may overwrite refs
|
|
|
|
other than the current branch (including local refs that are
|
|
|
|
strictly behind their remote counterpart). To force a push to only
|
|
|
|
one branch, use a `+` in front of the refspec to push (e.g `git push
|
|
|
|
origin +master` to force a push to the `master` branch). See the
|
|
|
|
`<refspec>...` section above for details.
|
2005-08-23 10:49:47 +02:00
|
|
|
|
2008-10-07 16:26:20 +02:00
|
|
|
--repo=<repository>::
|
|
|
|
This option is only relevant if no <repository> argument is
|
2010-01-10 00:33:00 +01:00
|
|
|
passed in the invocation. In this case, 'git push' derives the
|
2008-10-07 16:26:20 +02:00
|
|
|
remote name from the current branch: If it tracks a remote
|
|
|
|
branch, then that remote repository is pushed to. Otherwise,
|
|
|
|
the name "origin" is used. For this latter case, this option
|
|
|
|
can be used to override the name "origin". In other words,
|
|
|
|
the difference between these two commands
|
|
|
|
+
|
|
|
|
--------------------------
|
|
|
|
git push public #1
|
|
|
|
git push --repo=public #2
|
|
|
|
--------------------------
|
|
|
|
+
|
|
|
|
is that #1 always pushes to "public" whereas #2 pushes to "public"
|
|
|
|
only if the current branch does not track a remote branch. This is
|
2010-01-10 00:33:00 +01:00
|
|
|
useful if you write an alias or script around 'git push'.
|
2007-01-16 20:46:03 +01:00
|
|
|
|
2010-01-23 23:18:23 +01:00
|
|
|
-u::
|
|
|
|
--set-upstream::
|
|
|
|
For every branch that is up to date or successfully pushed, add
|
|
|
|
upstream (tracking) reference, used by argument-less
|
|
|
|
linkgit:git-pull[1] and other commands. For more information,
|
|
|
|
see 'branch.<name>.merge' in linkgit:git-config[1].
|
|
|
|
|
2013-05-09 03:16:55 +02:00
|
|
|
--[no-]thin::
|
2010-02-18 10:10:28 +01:00
|
|
|
These options are passed to linkgit:git-send-pack[1]. A thin transfer
|
|
|
|
significantly reduces the amount of sent data when the sender and
|
|
|
|
receiver share many of the same objects in common. The default is
|
|
|
|
\--thin.
|
2007-01-16 20:46:03 +01:00
|
|
|
|
2009-10-19 06:01:19 +02:00
|
|
|
-q::
|
|
|
|
--quiet::
|
|
|
|
Suppress all output, including the listing of updated refs,
|
2010-02-24 13:50:27 +01:00
|
|
|
unless an error occurs. Progress is not reported to the standard
|
|
|
|
error stream.
|
2009-10-19 06:01:19 +02:00
|
|
|
|
2008-06-08 03:36:09 +02:00
|
|
|
-v::
|
|
|
|
--verbose::
|
2007-01-16 20:46:03 +01:00
|
|
|
Run verbosely.
|
|
|
|
|
2010-02-24 13:50:27 +01:00
|
|
|
--progress::
|
|
|
|
Progress status is reported on the standard error stream
|
|
|
|
by default when it is attached to a terminal, unless -q
|
|
|
|
is specified. This flag forces progress status even if the
|
|
|
|
standard error stream is not directed to a terminal.
|
2009-10-19 06:01:19 +02:00
|
|
|
|
2012-03-29 09:21:24 +02:00
|
|
|
--recurse-submodules=check|on-demand::
|
|
|
|
Make sure all submodule commits used by the revisions to be
|
2012-10-23 13:34:05 +02:00
|
|
|
pushed are available on a remote-tracking branch. If 'check' is
|
2013-01-21 20:17:53 +01:00
|
|
|
used Git will verify that all submodule commits that changed in
|
2012-03-29 09:21:24 +02:00
|
|
|
the revisions to be pushed are available on at least one remote
|
|
|
|
of the submodule. If any commits are missing the push will be
|
|
|
|
aborted and exit with non-zero status. If 'on-demand' is used
|
|
|
|
all submodules that changed in the revisions to be pushed will
|
|
|
|
be pushed. If on-demand was not able to push all necessary
|
|
|
|
revisions it will also be aborted and exit with non-zero status.
|
2011-08-20 00:08:47 +02:00
|
|
|
|
2013-05-23 15:34:11 +02:00
|
|
|
--[no-]verify::
|
|
|
|
Toggle the pre-push hook (see linkgit:githooks[5]). The
|
|
|
|
default is \--verify, giving the hook a chance to prevent the
|
|
|
|
push. With \--no-verify, the hook is bypassed completely.
|
|
|
|
|
2011-08-20 00:08:47 +02:00
|
|
|
|
2007-07-05 00:21:36 +02:00
|
|
|
include::urls-remotes.txt[]
|
2005-12-05 09:32:01 +01:00
|
|
|
|
2008-02-19 17:26:45 +01:00
|
|
|
OUTPUT
|
|
|
|
------
|
|
|
|
|
|
|
|
The output of "git push" depends on the transport method used; this
|
2013-01-21 20:17:53 +01:00
|
|
|
section describes the output when pushing over the Git protocol (either
|
2008-02-19 17:26:45 +01:00
|
|
|
locally or via ssh).
|
|
|
|
|
|
|
|
The status of the push is output in tabular form, with each line
|
|
|
|
representing the status of a single ref. Each line is of the form:
|
|
|
|
|
|
|
|
-------------------------------
|
|
|
|
<flag> <summary> <from> -> <to> (<reason>)
|
|
|
|
-------------------------------
|
|
|
|
|
2009-06-23 03:10:01 +02:00
|
|
|
If --porcelain is used, then each line of the output is of the form:
|
|
|
|
|
|
|
|
-------------------------------
|
|
|
|
<flag> \t <from>:<to> \t <summary> (<reason>)
|
|
|
|
-------------------------------
|
|
|
|
|
2010-02-09 01:45:21 +01:00
|
|
|
The status of up-to-date refs is shown only if --porcelain or --verbose
|
|
|
|
option is used.
|
|
|
|
|
2008-02-19 17:26:45 +01:00
|
|
|
flag::
|
2010-02-09 01:45:21 +01:00
|
|
|
A single character indicating the status of the ref:
|
|
|
|
(space);; for a successfully pushed fast-forward;
|
docs: stop using asciidoc no-inline-literal
In asciidoc 7, backticks like `foo` produced a typographic
effect, but did not otherwise affect the syntax. In asciidoc
8, backticks introduce an "inline literal" inside which markup
is not interpreted. To keep compatibility with existing
documents, asciidoc 8 has a "no-inline-literal" attribute to
keep the old behavior. We enabled this so that the
documentation could be built on either version.
It has been several years now, and asciidoc 7 is no longer
in wide use. We can now decide whether or not we want
inline literals on their own merits, which are:
1. The source is much easier to read when the literal
contains punctuation. You can use `master~1` instead
of `master{tilde}1`.
2. They are less error-prone. Because of point (1), we
tend to make mistakes and forget the extra layer of
quoting.
This patch removes the no-inline-literal attribute from the
Makefile and converts every use of backticks in the
documentation to an inline literal (they must be cleaned up,
or the example above would literally show "{tilde}" in the
output).
Problematic sites were found by grepping for '`.*[{\\]' and
examined and fixed manually. The results were then verified
by comparing the output of "html2text" on the set of
generated html pages. Doing so revealed that in addition to
making the source more readable, this patch fixes several
formatting bugs:
- HTML rendering used the ellipsis character instead of
literal "..." in code examples (like "git log A...B")
- some code examples used the right-arrow character
instead of '->' because they failed to quote
- api-config.txt did not quote tilde, and the resulting
HTML contained a bogus snippet like:
<tt><sub></tt> foo <tt></sub>bar</tt>
which caused some parsers to choke and omit whole
sections of the page.
- git-commit.txt confused ``foo`` (backticks inside a
literal) with ``foo'' (matched double-quotes)
- mentions of `A U Thor <author@example.com>` used to
erroneously auto-generate a mailto footnote for
author@example.com
- the description of --word-diff=plain incorrectly showed
the output as "[-removed-] and {added}", not "{+added+}".
- using "prime" notation like:
commit `C` and its replacement `C'`
confused asciidoc into thinking that everything between
the first backtick and the final apostrophe were meant
to be inside matched quotes
- asciidoc got confused by the escaping of some of our
asterisks. In particular,
`credential.\*` and `credential.<url>.\*`
properly escaped the asterisk in the first case, but
literally passed through the backslash in the second
case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26 10:51:57 +02:00
|
|
|
`+`;; for a successful forced update;
|
2010-02-09 01:45:21 +01:00
|
|
|
`-`;; for a successfully deleted ref;
|
|
|
|
`*`;; for a successfully pushed new ref;
|
|
|
|
`!`;; for a ref that was rejected or failed to push; and
|
|
|
|
`=`;; for a ref that was up to date and did not need pushing.
|
2008-02-19 17:26:45 +01:00
|
|
|
|
|
|
|
summary::
|
|
|
|
For a successfully pushed ref, the summary shows the old and new
|
|
|
|
values of the ref in a form suitable for using as an argument to
|
|
|
|
`git log` (this is `<old>..<new>` in most cases, and
|
docs: stop using asciidoc no-inline-literal
In asciidoc 7, backticks like `foo` produced a typographic
effect, but did not otherwise affect the syntax. In asciidoc
8, backticks introduce an "inline literal" inside which markup
is not interpreted. To keep compatibility with existing
documents, asciidoc 8 has a "no-inline-literal" attribute to
keep the old behavior. We enabled this so that the
documentation could be built on either version.
It has been several years now, and asciidoc 7 is no longer
in wide use. We can now decide whether or not we want
inline literals on their own merits, which are:
1. The source is much easier to read when the literal
contains punctuation. You can use `master~1` instead
of `master{tilde}1`.
2. They are less error-prone. Because of point (1), we
tend to make mistakes and forget the extra layer of
quoting.
This patch removes the no-inline-literal attribute from the
Makefile and converts every use of backticks in the
documentation to an inline literal (they must be cleaned up,
or the example above would literally show "{tilde}" in the
output).
Problematic sites were found by grepping for '`.*[{\\]' and
examined and fixed manually. The results were then verified
by comparing the output of "html2text" on the set of
generated html pages. Doing so revealed that in addition to
making the source more readable, this patch fixes several
formatting bugs:
- HTML rendering used the ellipsis character instead of
literal "..." in code examples (like "git log A...B")
- some code examples used the right-arrow character
instead of '->' because they failed to quote
- api-config.txt did not quote tilde, and the resulting
HTML contained a bogus snippet like:
<tt><sub></tt> foo <tt></sub>bar</tt>
which caused some parsers to choke and omit whole
sections of the page.
- git-commit.txt confused ``foo`` (backticks inside a
literal) with ``foo'' (matched double-quotes)
- mentions of `A U Thor <author@example.com>` used to
erroneously auto-generate a mailto footnote for
author@example.com
- the description of --word-diff=plain incorrectly showed
the output as "[-removed-] and {added}", not "{+added+}".
- using "prime" notation like:
commit `C` and its replacement `C'`
confused asciidoc into thinking that everything between
the first backtick and the final apostrophe were meant
to be inside matched quotes
- asciidoc got confused by the escaping of some of our
asterisks. In particular,
`credential.\*` and `credential.<url>.\*`
properly escaped the asterisk in the first case, but
literally passed through the backslash in the second
case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26 10:51:57 +02:00
|
|
|
`<old>...<new>` for forced non-fast-forward updates).
|
2010-07-24 18:03:15 +02:00
|
|
|
+
|
|
|
|
For a failed update, more details are given:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
rejected::
|
|
|
|
Git did not try to send the ref at all, typically because it
|
|
|
|
is not a fast-forward and you did not force the update.
|
|
|
|
|
|
|
|
remote rejected::
|
|
|
|
The remote end refused the update. Usually caused by a hook
|
|
|
|
on the remote side, or because the remote repository has one
|
|
|
|
of the following safety options in effect:
|
|
|
|
`receive.denyCurrentBranch` (for pushes to the checked out
|
|
|
|
branch), `receive.denyNonFastForwards` (for forced
|
|
|
|
non-fast-forward updates), `receive.denyDeletes` or
|
|
|
|
`receive.denyDeleteCurrent`. See linkgit:git-config[1].
|
|
|
|
|
|
|
|
remote failure::
|
|
|
|
The remote end did not report the successful update of the ref,
|
|
|
|
perhaps because of a temporary error on the remote side, a
|
|
|
|
break in the network connection, or other transient error.
|
|
|
|
--
|
2008-02-19 17:26:45 +01:00
|
|
|
|
|
|
|
from::
|
|
|
|
The name of the local ref being pushed, minus its
|
|
|
|
`refs/<type>/` prefix. In the case of deletion, the
|
|
|
|
name of the local ref is omitted.
|
|
|
|
|
|
|
|
to::
|
|
|
|
The name of the remote ref being updated, minus its
|
|
|
|
`refs/<type>/` prefix.
|
|
|
|
|
|
|
|
reason::
|
|
|
|
A human-readable explanation. In the case of successfully pushed
|
|
|
|
refs, no explanation is needed. For a failed ref, the reason for
|
|
|
|
failure is described.
|
2007-06-09 20:01:23 +02:00
|
|
|
|
2009-08-08 09:51:08 +02:00
|
|
|
Note about fast-forwards
|
|
|
|
------------------------
|
|
|
|
|
|
|
|
When an update changes a branch (or more in general, a ref) that used to
|
|
|
|
point at commit A to point at another commit B, it is called a
|
|
|
|
fast-forward update if and only if B is a descendant of A.
|
|
|
|
|
|
|
|
In a fast-forward update from A to B, the set of commits that the original
|
|
|
|
commit A built on top of is a subset of the commits the new commit B
|
|
|
|
builds on top of. Hence, it does not lose any history.
|
|
|
|
|
|
|
|
In contrast, a non-fast-forward update will lose history. For example,
|
|
|
|
suppose you and somebody else started at the same commit X, and you built
|
|
|
|
a history leading to commit B while the other person built a history
|
|
|
|
leading to commit A. The history looks like this:
|
|
|
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
B
|
|
|
|
/
|
|
|
|
---X---A
|
|
|
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
Further suppose that the other person already pushed changes leading to A
|
2012-11-27 02:37:34 +01:00
|
|
|
back to the original repository from which you two obtained the original
|
|
|
|
commit X.
|
2009-08-08 09:51:08 +02:00
|
|
|
|
|
|
|
The push done by the other person updated the branch that used to point at
|
|
|
|
commit X to point at commit A. It is a fast-forward.
|
|
|
|
|
|
|
|
But if you try to push, you will attempt to update the branch (that
|
|
|
|
now points at A) with commit B. This does _not_ fast-forward. If you did
|
|
|
|
so, the changes introduced by commit A will be lost, because everybody
|
|
|
|
will now start building on top of B.
|
|
|
|
|
|
|
|
The command by default does not allow an update that is not a fast-forward
|
|
|
|
to prevent such loss of history.
|
|
|
|
|
2014-04-01 00:11:44 +02:00
|
|
|
If you do not want to lose your work (history from X to B) or the work by
|
2009-08-08 09:51:08 +02:00
|
|
|
the other person (history from X to A), you would need to first fetch the
|
|
|
|
history from the repository, create a history that contains changes done
|
|
|
|
by both parties, and push the result back.
|
|
|
|
|
|
|
|
You can perform "git pull", resolve potential conflicts, and "git push"
|
|
|
|
the result. A "git pull" will create a merge commit C between commits A
|
|
|
|
and B.
|
|
|
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
B---C
|
|
|
|
/ /
|
|
|
|
---X---A
|
|
|
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
Updating A with the resulting merge commit will fast-forward and your
|
|
|
|
push will be accepted.
|
|
|
|
|
|
|
|
Alternatively, you can rebase your change between X and B on top of A,
|
|
|
|
with "git pull --rebase", and push the result back. The rebase will
|
|
|
|
create a new commit D that builds the change between X and B on top of
|
|
|
|
A.
|
|
|
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
B D
|
|
|
|
/ /
|
|
|
|
---X---A
|
|
|
|
|
|
|
|
----------------
|
|
|
|
|
|
|
|
Again, updating A with this commit will fast-forward and your push will be
|
|
|
|
accepted.
|
|
|
|
|
|
|
|
There is another common situation where you may encounter non-fast-forward
|
|
|
|
rejection when you try to push, and it is possible even when you are
|
|
|
|
pushing 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.
|
|
|
|
|
|
|
|
|
2007-06-09 20:01:23 +02:00
|
|
|
Examples
|
|
|
|
--------
|
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 04:13:29 +02:00
|
|
|
`git push`::
|
2009-03-15 03:32:01 +01:00
|
|
|
Works like `git push <remote>`, where <remote> is the
|
|
|
|
current branch's remote (or `origin`, if no remote is
|
|
|
|
configured for the current branch).
|
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 04:13:29 +02:00
|
|
|
`git push origin`::
|
2013-01-05 01:02:29 +01:00
|
|
|
Without additional configuration, pushes the current branch to
|
|
|
|
the configured upstream (`remote.origin.merge` configuration
|
|
|
|
variable) if it has the same name as the current branch, and
|
|
|
|
errors out without pushing otherwise.
|
2009-03-15 03:32:01 +01:00
|
|
|
+
|
|
|
|
The default behavior of this command when no <refspec> is given can be
|
2012-10-02 17:38:00 +02:00
|
|
|
configured by setting the `push` option of the remote, or the `push.default`
|
|
|
|
configuration variable.
|
2009-03-15 03:32:01 +01:00
|
|
|
+
|
|
|
|
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`.
|
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 04:13:29 +02:00
|
|
|
`git push origin :`::
|
2009-03-15 03:32:01 +01:00
|
|
|
Push "matching" branches to `origin`. See
|
|
|
|
<refspec> in the <<OPTIONS,OPTIONS>> section above for a
|
|
|
|
description of "matching" branches.
|
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 04:13:29 +02:00
|
|
|
`git push origin master`::
|
2007-06-09 20:01:23 +02:00
|
|
|
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
|
2008-04-21 05:31:24 +02:00
|
|
|
with it. If `master` did not exist remotely, it would be
|
|
|
|
created.
|
2007-06-09 20:01:23 +02:00
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 04:13:29 +02:00
|
|
|
`git push origin HEAD`::
|
2009-01-26 00:45:32 +01:00
|
|
|
A handy way to push the current branch to the same name on the
|
|
|
|
remote.
|
2007-06-09 20:01:23 +02:00
|
|
|
|
2012-11-28 00:52:27 +01:00
|
|
|
`git push mothership master:satellite/master dev:satellite/dev`::
|
2008-07-30 01:13:38 +02:00
|
|
|
Use the source ref that matches `master` (e.g. `refs/heads/master`)
|
|
|
|
to update the ref that matches `satellite/master` (most probably
|
2012-11-28 00:52:27 +01:00
|
|
|
`refs/remotes/satellite/master`) in the `mothership` repository;
|
2008-07-30 01:13:38 +02:00
|
|
|
do the same for `dev` and `satellite/dev`.
|
2012-11-28 00:52:27 +01:00
|
|
|
+
|
|
|
|
This is to emulate `git fetch` run on the `mothership` using `git
|
|
|
|
push` that is run in the opposite direction in order to integrate
|
|
|
|
the work done on `satellite`, and is often necessary when you can
|
|
|
|
only make connection in one way (i.e. satellite can ssh into
|
|
|
|
mothership but mothership cannot initiate connection to satellite
|
|
|
|
because the latter is behind a firewall or does not run sshd).
|
|
|
|
+
|
|
|
|
After running this `git push` on the `satellite` machine, you would
|
|
|
|
ssh into the `mothership` and run `git merge` there to complete the
|
|
|
|
emulation of `git pull` that were run on `mothership` to pull changes
|
|
|
|
made on `satellite`.
|
2007-06-09 20:01:23 +02:00
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 04:13:29 +02:00
|
|
|
`git push origin HEAD:master`::
|
2009-01-26 00:45:32 +01:00
|
|
|
Push the current branch to the remote ref matching `master` in the
|
|
|
|
`origin` repository. This form is convenient to push the current
|
|
|
|
branch without thinking about its local name.
|
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 04:13:29 +02:00
|
|
|
`git push origin master:refs/heads/experimental`::
|
2007-09-06 06:44:08 +02:00
|
|
|
Create the branch `experimental` in the `origin` repository
|
2008-04-21 05:31:24 +02:00
|
|
|
by copying the current `master` branch. This form is only
|
|
|
|
needed to create a new branch or tag in the remote repository when
|
|
|
|
the local name and the remote name are different; otherwise,
|
|
|
|
the ref name on its own will work.
|
2007-09-06 06:44:08 +02:00
|
|
|
|
docs: put listed example commands in backticks
Many examples of git command invocation are given in asciidoc listing
blocks, which makes them monospaced and avoids further interpretation of
special characters. Some manpages make a list of examples, like:
git foo::
Run git foo.
git foo -q::
Use the "-q" option.
to quickly show many variants. However, they can sometimes be hard to
read, because they are shown in a proportional-width font (so, for
example, seeing the difference between "-- foo" and "--foo" can be
difficult).
This patch puts all such examples into backticks, which gives the
equivalent formatting to a listing block (i.e., monospaced and without
character interpretation).
As a bonus, this also fixes an example in the git-push manpage, in which
"git push origin :::" was accidentally considered a newly-indented list,
and not a list item with "git push origin :" in it.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-04 04:13:29 +02:00
|
|
|
`git push origin :experimental`::
|
2009-01-26 00:45:32 +01:00
|
|
|
Find a ref that matches `experimental` in the `origin` repository
|
|
|
|
(e.g. `refs/heads/experimental`), and delete it.
|
|
|
|
|
docs: stop using asciidoc no-inline-literal
In asciidoc 7, backticks like `foo` produced a typographic
effect, but did not otherwise affect the syntax. In asciidoc
8, backticks introduce an "inline literal" inside which markup
is not interpreted. To keep compatibility with existing
documents, asciidoc 8 has a "no-inline-literal" attribute to
keep the old behavior. We enabled this so that the
documentation could be built on either version.
It has been several years now, and asciidoc 7 is no longer
in wide use. We can now decide whether or not we want
inline literals on their own merits, which are:
1. The source is much easier to read when the literal
contains punctuation. You can use `master~1` instead
of `master{tilde}1`.
2. They are less error-prone. Because of point (1), we
tend to make mistakes and forget the extra layer of
quoting.
This patch removes the no-inline-literal attribute from the
Makefile and converts every use of backticks in the
documentation to an inline literal (they must be cleaned up,
or the example above would literally show "{tilde}" in the
output).
Problematic sites were found by grepping for '`.*[{\\]' and
examined and fixed manually. The results were then verified
by comparing the output of "html2text" on the set of
generated html pages. Doing so revealed that in addition to
making the source more readable, this patch fixes several
formatting bugs:
- HTML rendering used the ellipsis character instead of
literal "..." in code examples (like "git log A...B")
- some code examples used the right-arrow character
instead of '->' because they failed to quote
- api-config.txt did not quote tilde, and the resulting
HTML contained a bogus snippet like:
<tt><sub></tt> foo <tt></sub>bar</tt>
which caused some parsers to choke and omit whole
sections of the page.
- git-commit.txt confused ``foo`` (backticks inside a
literal) with ``foo'' (matched double-quotes)
- mentions of `A U Thor <author@example.com>` used to
erroneously auto-generate a mailto footnote for
author@example.com
- the description of --word-diff=plain incorrectly showed
the output as "[-removed-] and {added}", not "{+added+}".
- using "prime" notation like:
commit `C` and its replacement `C'`
confused asciidoc into thinking that everything between
the first backtick and the final apostrophe were meant
to be inside matched quotes
- asciidoc got confused by the escaping of some of our
asterisks. In particular,
`credential.\*` and `credential.<url>.\*`
properly escaped the asterisk in the first case, but
literally passed through the backslash in the second
case.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-26 10:51:57 +02:00
|
|
|
`git push origin +dev:master`::
|
2009-02-19 18:39:47 +01:00
|
|
|
Update the origin repository's master branch with the dev branch,
|
2009-10-24 10:31:32 +02:00
|
|
|
allowing non-fast-forward updates. *This can leave unreferenced
|
2009-02-19 18:39:47 +01:00
|
|
|
commits dangling in the origin repository.* Consider the
|
2009-10-24 10:31:32 +02:00
|
|
|
following situation, where a fast-forward is not possible:
|
2009-02-19 18:39:47 +01:00
|
|
|
+
|
|
|
|
----
|
|
|
|
o---o---o---A---B origin/master
|
|
|
|
\
|
|
|
|
X---Y---Z dev
|
|
|
|
----
|
|
|
|
+
|
|
|
|
The above command would change the origin repository to
|
|
|
|
+
|
|
|
|
----
|
|
|
|
A---B (unnamed branch)
|
|
|
|
/
|
|
|
|
o---o---o---X---Y---Z master
|
|
|
|
----
|
|
|
|
+
|
|
|
|
Commits A and B would no longer belong to a branch with a symbolic name,
|
|
|
|
and so would be unreachable. As such, these commits would be removed by
|
|
|
|
a `git gc` command on the origin repository.
|
|
|
|
|
2005-08-23 10:49:47 +02:00
|
|
|
GIT
|
|
|
|
---
|
2008-06-06 09:07:32 +02:00
|
|
|
Part of the linkgit:git[1] suite
|