making "git stash" safer to use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Through a simple typo I lost modifications to 20 files:

> >>>     $ git stash
> >>>     $ git pull
> >>>     $ git stash apply
> >>>     $ git stash clean              # typo!
> >>>     $ git stash clear              # fatal correction to typo!

It is just too easy to lose your modifications by using "git stash".

Eric Blake further says:

> While we're at it, I wish 'git stash clear' would take an optional
> argument that says which stash(es) to clear, rather than blindly clearing
> the entire stash.

It would help if git would store which of the stashes were applied since
they were created and which were not. A stash that was not yet applied must
be considered "precious", whereas a stash that was applied is redundant,
right?

According these lines, how about
  1) changing "git stash clear" to remove only the redundant stashes,
     (or alternatively: let it fail if there is at least one precious stash),
  2) adding an option -f, so that "git stash -f clear" clears all stashes,
     including the precious ones.

The rationale is that humans are bad at remembering the state of something.
Therefore instead of having a command that is commonly used in one state
and dangerous in the other state, better have two different commands - one
for the common case, and one for the dangerous one. Like "rm" and "rm -f".

Bruno

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux