git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Vipul <finn02@disroot.org>
Cc: git@vger.kernel.org
Subject: Re: Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands
Date: Tue, 27 Aug 2019 15:05:10 -0400	[thread overview]
Message-ID: <20190827190509.GB3150@sigill.intra.peff.net> (raw)
In-Reply-To: <c1136131-0a9e-9dbb-3ad7-495ac96c1ef0@disroot.org>

On Tue, Aug 27, 2019 at 09:53:30AM +0000, Vipul wrote:

> Sometimes, I messed-up with git repository and lost works due
> carelessness. This includes reset a branch instead of other, drop the
> stash etc by mistake. I wonder, is there way to a get an interactive
> confirmation prompt (which ask for yes/no option) before executing those
> commands when users can possibly lose their work? Like, some UNIX
> commands have support for an interactive prompt (like 'rm -i', 'mv -i',
> 'cp -i', etc) for ex: before deleting and overwriting a file a
> confirmation is prompt and asking for users permission.
> 	If there would no such feature available in git, so how do other people
> avoid these kind of mistakes?

The usual philosophy in Git is not to bother the user with
confirmations, but to allow recovery after a mistake.

If you've moved a branch pointer around (e.g., via "git branch -f" or
"git reset"), you can recover it from the reflog.

In the case of a mistakenly dropped stash, there's no reflog (the stash
list itself is implemented as a reflog!), but you can use "git fsck" to
generate a list of "dangling" commits. These are commits which are
unreferenced, but they hang around until at least the next git-gc run.

Note that there _are_ some commands which are not reversible: mostly
things that drop content from the working tree. So "git reset --hard" is
one, and "git clean" is another. There have been discussions and even
some patches about storing the lost in an "undo log", but nothing has
been merged.

-Peff

  reply	other threads:[~2019-08-27 19:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27  9:53 Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands Vipul
2019-08-27 19:05 ` Jeff King [this message]
2019-08-27 22:42   ` Vipul
2019-08-28 15:05     ` Jeff King
2019-08-28 15:27       ` Duy Nguyen
2019-08-27 22:22 ` Pratyush Yadav

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=20190827190509.GB3150@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=finn02@disroot.org \
    --cc=git@vger.kernel.org \
    /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).