convert less-trivial versions of "write_in_full() != len"
[gitweb.git] / Documentation / git-push.txt
index cf6ee4a4df5f91f585591c314854ed1a332d8909..0a639664fd67f497b1597cf903015a284947509d 100644 (file)
@@ -11,7 +11,7 @@ SYNOPSIS
 [verse]
 'git push' [--all | --mirror | --tags] [--follow-tags] [--atomic] [-n | --dry-run] [--receive-pack=<git-receive-pack>]
           [--repo=<repository>] [-f | --force] [-d | --delete] [--prune] [-v | --verbose]
-          [-u | --set-upstream]
+          [-u | --set-upstream] [--push-option=<string>]
           [--[no-]signed|--sign=(true|false|if-asked)]
           [--force-with-lease[=<refname>[:<expect>]]]
           [--no-verify] [<repository> [<refspec>...]]
@@ -137,8 +137,8 @@ already exists on the remote side.
        and also push annotated tags in `refs/tags` that are missing
        from the remote but are pointing at commit-ish that are
        reachable from the refs being pushed.  This can also be specified
-       with configuration variable 'push.followTags'.  For more
-       information, see 'push.followTags' in linkgit:git-config[1].
+       with configuration variable `push.followTags`.  For more
+       information, see `push.followTags` in linkgit:git-config[1].
 
 --[no-]signed::
 --sign=(true|false|if-asked)::
@@ -156,6 +156,12 @@ already exists on the remote side.
        Either all refs are updated, or on error, no refs are updated.
        If the server does not support atomic pushes the push will fail.
 
+-o::
+--push-option::
+       Transmit the given string to the server, which passes them to
+       the pre-receive as well as the post-receive hook. The given string
+       must not contain a NUL or LF character.
+
 --receive-pack=<git-receive-pack>::
 --exec=<git-receive-pack>::
        Path to the 'git-receive-pack' program on the remote
@@ -198,10 +204,11 @@ 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
+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).
+this form is used).  If `<expect>` is the empty string, then the named ref
+must not already exist.
 +
 Note that all forms other than `--force-with-lease=<refname>:<expect>`
 that specifies the expected current value of the ref explicitly are
@@ -210,6 +217,47 @@ with this feature.
 +
 "--no-force-with-lease" will cancel all the previous --force-with-lease on the
 command line.
++
+A general note on safety: supplying this option without an expected
+value, i.e. as `--force-with-lease` or `--force-with-lease=<refname>`
+interacts very badly with anything that implicitly runs `git fetch` on
+the remote to be pushed to in the background, e.g. `git fetch origin`
+on your repository in a cronjob.
++
+The protection it offers over `--force` is ensuring that subsequent
+changes your work wasn't based on aren't clobbered, but this is
+trivially defeated if some background process is updating refs in the
+background. We don't have anything except the remote tracking info to
+go by as a heuristic for refs you're expected to have seen & are
+willing to clobber.
++
+If your editor or some other system is running `git fetch` in the
+background for you a way to mitigate this is to simply set up another
+remote:
++
+       git remote add origin-push $(git config remote.origin.url)
+       git fetch origin-push
++
+Now when the background process runs `git fetch origin` the references
+on `origin-push` won't be updated, and thus commands like:
++
+       git push --force-with-lease origin-push
++
+Will fail unless you manually run `git fetch origin-push`. This method
+is of course entirely defeated by something that runs `git fetch
+--all`, in that case you'd need to either disable it or do something
+more tedious like:
++
+       git fetch              # update 'master' from remote
+       git tag base master    # mark our base point
+       git rebase -i master   # rewrite some commits
+       git push --force-with-lease=master:base master:master
++
+I.e. create a `base` tag for versions of the upstream code that you've
+seen and are willing to overwrite, then rewrite history, and finally
+force push changes to `master` if the remote version is still at
+`base`, regardless of what your local `remotes/origin/master` has been
+updated to in the background.
 
 -f::
 --force::
@@ -240,7 +288,7 @@ origin +master` to force a push to the `master` branch). See the
        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].
+       see `branch.<name>.merge` in linkgit:git-config[1].
 
 --[no-]thin::
        These options are passed to linkgit:git-send-pack[1]. A thin transfer
@@ -265,7 +313,7 @@ origin +master` to force a push to the `master` branch). See the
        standard error stream is not directed to a terminal.
 
 --no-recurse-submodules::
---recurse-submodules=check|on-demand|no::
+--recurse-submodules=check|on-demand|only|no::
        May be used to make sure all submodule commits used by the
        revisions to be pushed are available on a remote-tracking branch.
        If 'check' is used Git will verify that all submodule commits that
@@ -273,11 +321,12 @@ origin +master` to force a push to the `master` branch). See the
        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. A value of
-       'no' or using '--no-recurse-submodules' can be used to override the
-       push.recurseSubmodules configuration variable when no submodule
-       recursion is required.
+       pushed. If on-demand was not able to push all necessary revisions it will
+       also be aborted and exit with non-zero status. If 'only' is used all
+       submodules will be recursively pushed while the superproject is left
+       unpushed. A value of 'no' or using `--no-recurse-submodules` can be used
+       to override the push.recurseSubmodules configuration variable when no
+       submodule recursion is required.
 
 --[no-]verify::
        Toggle the pre-push hook (see linkgit:githooks[5]).  The
@@ -552,6 +601,8 @@ 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.
 
+include::transfer-data-leaks.txt[]
+
 GIT
 ---
 Part of the linkgit:git[1] suite