From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: Dany <nessup@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Feature request: prevent push -f from pushing all branches at once
Date: Thu, 04 Jul 2013 10:06:59 +0200 [thread overview]
Message-ID: <vpq7gh67nq4.fsf@anie.imag.fr> (raw)
In-Reply-To: <ADE9FE42-FC10-4976-8E6A-290B101DD17A@gmail.com> (Dany's message of "Wed, 3 Jul 2013 16:30:27 -0700")
Dany <nessup@gmail.com> writes:
> Again, I think the case where one intends to force push many branches
> is certainly not as common as the case where one intends to force push
> one branch, so why does git's default behavior leave the user in the
> position of fscking himself over pretty badly?
I don't think the case of "force push" is very different from the
"non-force push". If you're surprised that "git push -f" pushes
everything, most likely you didn't want a plain "git push" to push
everything either.
There are already several measures against this. The first is mentionned
in Jonathan's message: Git 2.0 will only push one branch by default (-f
or not). You can already get this behavior by setting push.default (if
your Git version is too old, set it to "current" for example, read "git
config --help").
Another measure is a better documentation. We've just merged the change
below. In short: don't run "git push -f", but run e.g. "git push origin
+master".
commit 70495b556f5685afe0e41988e42d48b2331d77a0
Author: Matthieu Moy <Matthieu.Moy@imag.fr>
Date: Mon Jun 17 19:52:41 2013 +0200
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 <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/Documentation/git-push.txt b/Documentation/git-push.txt
index 8b637d3..28a17c3 100644
--- a/Documentation/git-push.txt
+++ b/Documentation/git-push.txt
@@ -124,6 +124,15 @@ no `push.default` configuration variable is set.
not an ancestor of the local ref used to overwrite it.
This flag disables the check. This 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.
--repo=<repository>::
This option is only relevant if no <repository> argument is
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
prev parent reply other threads:[~2013-07-04 8:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-03 23:30 Feature request: prevent push -f from pushing all branches at once Dany
2013-07-03 23:38 ` Jonathan Nieder
2013-07-04 8:06 ` Matthieu Moy [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpq7gh67nq4.fsf@anie.imag.fr \
--to=matthieu.moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=nessup@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.