Re: [PATCH] cmd_reset: don't trash uncommitted changes unless told to

3 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] cmd_reset: don't trash uncommitted changes unless told to

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:44:49

"Avery Pennarun" [off-list ref] writes:
How about making "git checkout" default to HEAD if no revision is
supplied?  There's precedent for this in, say, git-diff (and I think a
few others).
Won't fly.  'git checkout -- "$@"' is to revert to the last staged
version.

 * You say "git checkout branch" when you want to "check out that branch";

 * You say "git checkout -- file" when you want to "check out the file
   from the index";

 * You say "git checkout v1.5 -- file" when you want to "check out the
   file out of that revision".

It's not that hard.

Re: [PATCH] cmd_reset: don't trash uncommitted changes unless told to

From: Avery Pennarun <hidden>
Date: 2016-06-15 22:44:49

On 6/25/08, Junio C Hamano [off-list ref] wrote:
"Avery Pennarun" [off-list ref] writes:

 > How about making "git checkout" default to HEAD if no revision is
 > supplied?  There's precedent for this in, say, git-diff (and I think a
 > few others).

Won't fly.  'git checkout -- "$@"' is to revert to the last staged
 version.
Ah, I didn't catch the difference between HEAD and index there.
  * You say "git checkout -- file" when you want to "check out the file
   from the index";
The real question here is the --.  Is it strictly needed?  It's
optional in things like git-diff, which just do their best to guess
what you mean if you don't use the --.

If reset and checkout made the -- optional, then you could do:

git reset filename         # undo an accidental "add"
git checkout filename  # undo accidental modifications that haven't been added

...and save git reset --hard for people willing to take that risk.
(The fact that git-gui includes git reset --hard as a really
easy-to-click GUI command scared me the first time I saw it, too.)

I think simplifying the syntax might help to make the role of the
index less mysterious in the whole "revert" operation.  It's not
obvious to me at all whether a revert-file ought to get the one from
HEAD or the one from the index.  But I can easily understand and
explain checkout (copy index to working copy) and reset (undo an add).

Thanks,

Avery

Re: [PATCH] cmd_reset: don't trash uncommitted changes unless told to

From: Steven Walter <hidden>
Date: 2016-06-15 22:44:49

On Wed, Jun 25, 2008 at 4:11 PM, Junio C Hamano [off-list ref] wrote:
 * You say "git checkout branch" when you want to "check out that branch";

 * You say "git checkout -- file" when you want to "check out the file
  from the index";

 * You say "git checkout v1.5 -- file" when you want to "check out the
  file out of that revision".

It's not that hard.
No, it's not "that hard."  But are you really claiming that it's
beyond improvement?
-- 
-Steven Walter [off-list ref]
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help