git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "George Spelvin" <linux@horizon.com>
Cc: git@vger.kernel.org
Subject: Re: receive.denyCurrentBranch
Date: Sat, 07 Feb 2009 22:43:16 -0800	[thread overview]
Message-ID: <7vwsc11la3.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 20090208042910.19079.qmail@science.horizon.com

"George Spelvin" <linux@horizon.com> writes:

> (Prompted by the 1.6.2-rc0 announcement.)
>
> Myself, I always thought the obvious way to handle this problem was to
> detach the HEAD.  Is there a reson there's no "detach" option for this?

Let's first think about why pushing into the current branch with the
traditional behaviour is bad.

If you are in control of the remote whose current branch was checked out
when push was made, there are two cases:

 (1) You do not know what you are doing.  The first time you do "git diff
     HEAD", or perhaps "git status", you suddenly see a lot of reverts,
     sctach your head and cry for help;

     If you set 'detach' option, this clueless user is not helped; he will
     happily keep working and would make tons of commits on detached HEAD,
     and next time he switches to another branch, will lose all of them.

     In a sense, this is a lot worse than the current behaviour, because
     you will do a lot more damage than just a single commit that has many
     uninteniontal reverts as what currently happens---which can be sorted
     out.

 (2) You know what you are doing.  You'd say:

	: detach HEAD at the commit before the push updated the branch
	$ git checkout @{1}  
	$ work work work
        $ git commit

     to detach the HEAD, finish the work you were doing in the pushed-into
     repository and then:

	: check out the previous branch (i.e. go back)
	$ git checkout @{-1}
	: merge the last commit, i.e. the work you done on detached HEAD
        $ git merge @{1}

    If you allow 'detach' option, then you saved him from typing "git
    checkout @{1}".  Not a big gain, especially if you compare this with
    increased pain you are causing to people in category (1).

The case where the pushed-into repository is not yours was discussed
previously by Jeff King in the second thread below.

Previous discussions.

    http://thread.gmane.org/gmane.comp.version-control.git/35770/focus=36291
    http://thread.gmane.org/gmane.comp.version-control.git/100339/focus=100731

  reply	other threads:[~2009-02-08  6:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-08  4:29 receive.denyCurrentBranch George Spelvin
2009-02-08  6:43 ` Junio C Hamano [this message]
2009-02-08 10:30 ` receive.denyCurrentBranch Johannes Schindelin
2009-02-08 17:50   ` receive.denyCurrentBranch Jay Soffian
2009-02-08 20:54     ` receive.denyCurrentBranch Johannes Schindelin
2009-02-08 22:16       ` receive.denyCurrentBranch Jay Soffian
2009-02-08 22:51       ` receive.denyCurrentBranch Jay Soffian
2009-02-08 23:41         ` receive.denyCurrentBranch Johannes Schindelin
2009-02-09  1:38           ` receive.denyCurrentBranch Junio C Hamano
2009-02-09  1:47           ` receive.denyCurrentBranch Jay Soffian
2009-02-09  5:06             ` receive.denyCurrentBranch Theodore Tso
2009-02-09 11:06               ` receive.denyCurrentBranch Johannes Schindelin
2009-02-09 15:46                 ` receive.denyCurrentBranch Jay Soffian
2009-02-09 15:43               ` receive.denyCurrentBranch Jay Soffian
2009-02-08 22:03     ` receive.denyCurrentBranch Jakub Narebski

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=7vwsc11la3.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=linux@horizon.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).