Skip to content

Commit 70495b5

Browse files
moygitster
authored andcommitted
Documentation/git-push.txt: explain better cases where --force is dangerous
The behavior of "git push --force" is rather clear when it updates only one remote ref, but running it when pushing several branches can really be dangerous. Warn the users a bit more and give them the alternative to push only one branch. Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 04a74b6 commit 70495b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Documentation/git-push.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ no `push.default` configuration variable is set.
124124
not an ancestor of the local ref used to overwrite it.
125125
This flag disables the check. This can cause the
126126
remote repository to lose commits; use it with care.
127+
Note that `--force` applies to all the refs that are pushed,
128+
hence using it with `push.default` set to `matching` or with
129+
multiple push destinations configured with `remote.*.push`
130+
may overwrite refs other than the current branch (including
131+
local refs that are strictly behind their remote counterpart).
132+
To force a push to only one branch, use a `+` in front of the
133+
refspec to push (e.g `git push origin +master` to force a push
134+
to the `master` branch). See the `<refspec>...` section above
135+
for details.
127136

128137
--repo=<repository>::
129138
This option is only relevant if no <repository> argument is

0 commit comments

Comments
 (0)