Git development
 help / color / mirror / Atom feed
From: "Philip Oakley" <philipoakley@iee.org>
To: "Atsushi Nakagawa" <atnak@chejz.com>, "Kevin Bracey" <kevin@bracey.fi>
Cc: <git@vger.kernel.org>
Subject: Re: Reset by checkout?
Date: Sat, 7 Jun 2014 15:52:58 +0100	[thread overview]
Message-ID: <241E3E5EB7AE44E6821EA5DFAA24C28F@PhilipOakley> (raw)
In-Reply-To: 20140607135439.7893.B013761@chejz.com

From: "Atsushi Nakagawa" <atnak@chejz.com>
> Kevin Bracey <kevin@bracey.fi> wrote:
>> On 01/06/2014 07:26, Atsushi Nakagawa wrote:
>> > Kevin Bracey <kevin@bracey.fi> wrote:
>> >> The original "git reset --hard" used to be a pretty top-level 
>> >> command.
>> >> It was used for aborting merges in particular. But I think it now
>> >> stands out as being one of the only really dangerous porcelain
>> >> commands, and I can't think of any real workflow it's still useful
>> >> for.
>> > My thoughts exactly.  I think the 'reset --soft/--mixed/--hard' 
>> > pattern
>> > is so ingrained, that many people just don't realize there's a 
>> > safer
>> > alternative.  (I've heard work mates on more than one occasion
>> > recommending 'reset --hard' as the go-to command for discarding 
>> > commits.)
>> >
>> > I believe this is likely because many third party GUI tools just 
>> > don't
>> > support 'reset --keep', and these tools present a "Reset..." dialog 
>> > with
>> > the de facto Soft/Mixed/Hard options.  (Even 'gitk' does this.)
>> True on the GUI - "hard" really needs demotion.
>>
>> It would help if the documentation explained better straight off what
>> the different reset modes are intended /for/ in a more practical way,
>> rather than the technical jargon.
>
> On one hand, I agree that improving man git-reset and making it easier
> to understand would be of benefit.
>
> However, one of the main culprits of confusion here seems to be the 
> mere
> existance of '--keep', which is somewhat of a conceptual black sheep.
>
> The --soft/--mixed/--hard trio seems quite easy to explain, /if/ you
> didn't need to also explain --keep...
>
> To that end, I'm wondering if it's better to just deprecate 'reset
> --keep' and shift the use-case over to 'checkout':
>
> checkout [-u|--update] [<commit>|<branch>]
>
> -u
> --update
>    Rather than checking out a branch to work on it, check out a commit
>    and reset the current branch to that commit.
>
>    This is functionally equivalent to 'checkout -B CURRENT_BRANCH 
> <commit>'.
>
>    (...Maybe a warning here about commits becoming unreachable...)
>
>
> Then, as an added bonus, anything I've staged is kept intact.  *And*, 
> I
> can attempt 'checkout -u --merge' if I'm feeling particulary careless.
>
>> --hard
>>     All [] changes are dropped[] and the [working tree] and index are
>>     forcibly reset to the [state of <commit>].  Note that this is
>>     dangerous if used carelessly.  ALL uncommitted changes to ALL
>>     tracked files will be lost[].
>>
>>     Older documentation often recommends "git reset --hard" to
>>     undo commits; the newer "--keep" option is [safer and is now the
>>     recommended] alternative [for use in this situation].
>
> I like this explaination of '--hard' and prefer it over current, which
> doesn't much explain the gravity of the command.  I've made some edits
> above.
>
>> --merge
>>     Performs the operation of "git merge --abort", intended for use
>>     during a merge resolution - see git-merge(1) for more 
>> information.
>>     This form is not normally used directly.
>
> Aha, so that's what that's for.  I couldn't really understand the
> explanation in the current manpage, but your version at least tells me
> that it's an option I don't need to worry about.
>

Just to say there has been a similar confusion about 'git reset' 
reported on the Git Users group for the case of reset with added 
(staged), but uncommitted changes being wiped out, which simlarly 
reports on the difficulty of explaining some of the conditions 
especially when some are wrong ;-)

 https://groups.google.com/forum/#!topic/git-users/27_FxIV_100


--
Philip 

  reply	other threads:[~2014-06-07 14:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-31  5:46 Reset by checkout? Atsushi Nakagawa
2014-05-31  7:03 ` Andreas Schwab
2014-06-01  2:56   ` Atsushi Nakagawa
2014-05-31  7:27 ` Kevin Bracey
2014-06-01  4:26   ` Atsushi Nakagawa
2014-06-01  8:45     ` Kevin Bracey
2014-06-02 21:54       ` Junio C Hamano
2014-06-03 19:48         ` Kevin Bracey
2014-06-03 21:48           ` Felipe Contreras
2014-06-07  4:54       ` Atsushi Nakagawa
2014-06-07 14:52         ` Philip Oakley [this message]
2014-06-09 20:12           ` Kevin Bracey
2014-06-07  4:55     ` Atsushi Nakagawa
2014-05-31 10:56 ` Felipe Contreras
2014-05-31 23:39   ` Felipe Contreras
2014-06-01  4:58     ` Atsushi Nakagawa
2014-06-02 21:29 ` Junio C Hamano
2014-06-02 21:31   ` Junio C Hamano

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=241E3E5EB7AE44E6821EA5DFAA24C28F@PhilipOakley \
    --to=philipoakley@iee.org \
    --cc=atnak@chejz.com \
    --cc=git@vger.kernel.org \
    --cc=kevin@bracey.fi \
    /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