{"thread":{"id":"51756","subject":"Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands","startedAt":"2019-08-27T10:00:03Z","lastAt":"2019-08-28T15:28:03Z","messageCount":6,"participants":["Vipul","Jeff King","Pratyush Yadav","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"381333","messageId":"c1136131-0a9e-9dbb-3ad7-495ac96c1ef0@disroot.org","threadId":"51756","inReplyTo":null,"subject":"Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands","fromName":"Vipul","fromEmail":"finn02@disroot.org","sentAt":"2019-08-27T09:53:30Z","receivedAt":"2019-08-27T10:00:03Z","isPatch":false,"sender":{"key":"finn02@disroot.org","avatar":null},"body":"Hi,\n\nSometimes, I messed-up with git repository and lost works due\ncarelessness. This includes reset a branch instead of other, drop the\nstash etc by mistake. I wonder, is there way to a get an interactive\nconfirmation prompt (which ask for yes/no option) before executing those\ncommands when users can possibly lose their work? Like, some UNIX\ncommands have support for an interactive prompt (like 'rm -i', 'mv -i',\n'cp -i', etc) for ex: before deleting and overwriting a file a\nconfirmation is prompt and asking for users permission.\n\tIf there would no such feature available in git, so how do other people\navoid these kind of mistakes? Obviously, one them would be recheck the\ncommand carefully before executing it and repo status but, I think\nsometimes people also do these kind of mistakes. For now, to minimize\nsome of these kind problems I've modified my bash shell prompt to show\nall kind information related to a git repository by sourcing\n\"git-prompt\" script (provided with git package) and turn on all of flags\nprovided by it which significantly increase my productivity and less\nmistakes than earlier. But, anything else I can do to avoid these kind\nof mistakes at first place or increase my productivity (it includes\nadopting some best practices, using some command line tools etc).\n  \tI searched it on the Internet and found that there are many GUI tools\navailable which help with these problems but don't want to use GUI tools\nbecause most of time I work in command line environment and love using\ncommand line tool than GUI one.\n\nAny help would be greatly appreciated. Thanks.\n\nPS: Sometimes, I would recover my work by seeking some help mostly on\n#git IRC but, it would be better avoid this kind of mess at first place.\n\nCheers,\nVipul\n\n"},{"id":"381386","messageId":"20190827190509.GB3150@sigill.intra.peff.net","threadId":"51756","inReplyTo":"c1136131-0a9e-9dbb-3ad7-495ac96c1ef0@disroot.org","subject":"Re: Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-08-27T19:05:10Z","receivedAt":"2019-08-27T19:05:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 27, 2019 at 09:53:30AM +0000, Vipul wrote:\n\n> Sometimes, I messed-up with git repository and lost works due\n> carelessness. This includes reset a branch instead of other, drop the\n> stash etc by mistake. I wonder, is there way to a get an interactive\n> confirmation prompt (which ask for yes/no option) before executing those\n> commands when users can possibly lose their work? Like, some UNIX\n> commands have support for an interactive prompt (like 'rm -i', 'mv -i',\n> 'cp -i', etc) for ex: before deleting and overwriting a file a\n> confirmation is prompt and asking for users permission.\n> \tIf there would no such feature available in git, so how do other people\n> avoid these kind of mistakes?\n\nThe usual philosophy in Git is not to bother the user with\nconfirmations, but to allow recovery after a mistake.\n\nIf you've moved a branch pointer around (e.g., via \"git branch -f\" or\n\"git reset\"), you can recover it from the reflog.\n\nIn the case of a mistakenly dropped stash, there's no reflog (the stash\nlist itself is implemented as a reflog!), but you can use \"git fsck\" to\ngenerate a list of \"dangling\" commits. These are commits which are\nunreferenced, but they hang around until at least the next git-gc run.\n\nNote that there _are_ some commands which are not reversible: mostly\nthings that drop content from the working tree. So \"git reset --hard\" is\none, and \"git clean\" is another. There have been discussions and even\nsome patches about storing the lost in an \"undo log\", but nothing has\nbeen merged.\n\n-Peff\n"},{"id":"381401","messageId":"20190827222224.yypf3ydvsebxypb6@yadavpratyush.com","threadId":"51756","inReplyTo":"c1136131-0a9e-9dbb-3ad7-495ac96c1ef0@disroot.org","subject":"Re: Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands","fromName":"Pratyush Yadav","fromEmail":"me@yadavpratyush.com","sentAt":"2019-08-27T22:22:24Z","receivedAt":"2019-08-27T22:22:29Z","isPatch":false,"sender":{"key":"me@yadavpratyush.com","avatar":"https://avatars.githubusercontent.com/u/8817931?v=4"},"body":"On 27/08/19 09:53AM, Vipul wrote:\n> Hi,\n> \n> Sometimes, I messed-up with git repository and lost works due\n> carelessness. This includes reset a branch instead of other, drop the\n> stash etc by mistake. I wonder, is there way to a get an interactive\n> confirmation prompt (which ask for yes/no option) before executing those\n> commands when users can possibly lose their work? Like, some UNIX\n> commands have support for an interactive prompt (like 'rm -i', 'mv -i',\n> 'cp -i', etc) for ex: before deleting and overwriting a file a\n> confirmation is prompt and asking for users permission.\n> \tIf there would no such feature available in git, so how do other people\n> avoid these kind of mistakes? Obviously, one them would be recheck the\n> command carefully before executing it and repo status but, I think\n> sometimes people also do these kind of mistakes. For now, to minimize\n> some of these kind problems I've modified my bash shell prompt to show\n> all kind information related to a git repository by sourcing\n> \"git-prompt\" script (provided with git package) and turn on all of flags\n> provided by it which significantly increase my productivity and less\n> mistakes than earlier. But, anything else I can do to avoid these kind\n> of mistakes at first place or increase my productivity (it includes\n> adopting some best practices, using some command line tools etc).\n>   \tI searched it on the Internet and found that there are many GUI tools\n> available which help with these problems but don't want to use GUI tools\n> because most of time I work in command line environment and love using\n> command line tool than GUI one.\n \nOn top of Jeff's great answer, I'll add that I try to not keep my work \nlocal for too long. I usually push out changes, even when they are WIP, \nto a fork kept on a server somewhere (GitHub for my personal projects). \nThis way, if I mess up something real bad, I can clone the repo from the \nserver and recover my work, at least partially.\n\n[snip]\n\n-- \nRegards,\nPratyush Yadav\n"},{"id":"381405","messageId":"664344cb-f9e4-d4fc-fd14-620e3e10157a@disroot.org","threadId":"51756","inReplyTo":"20190827190509.GB3150@sigill.intra.peff.net","subject":"Re: Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands","fromName":"Vipul","fromEmail":"finn02@disroot.org","sentAt":"2019-08-27T22:42:03Z","receivedAt":"2019-08-27T22:42:27Z","isPatch":false,"sender":{"key":"finn02@disroot.org","avatar":null},"body":"Jeff King wrote:\n> The usual philosophy in Git is not to bother the user with\n> confirmations, but to allow recovery after a mistake.\n> \n\nWell, always prompting for confirmation will be annoying for some people\nspecially who are mastered in git but, may be very useful feature for\nbeginner's to avoid them from making mistakes. May be, this feature will\nbe disabled by default and users have to set some config variable (like\nother git-config variable for example help.autocorrect etc) in global\ngitconfig file.\n\n> If you've moved a branch pointer around (e.g., via \"git branch -f\" or\n> \"git reset\"), you can recover it from the reflog.\n> \n\nRecovery is not a problem, asking for help on #git IRC people will tell\nyou whether data is recoverable. If recoverable, they will even guide\nyou step-by-step. But, I think it would be good idea to not make these\nkind of mistakes at first place. Ultimately, we as a developer want to\nmake software more user-friendly and usable for normal users.\n\n> Note that there _are_ some commands which are not reversible: mostly\n> things that drop content from the working tree. So \"git reset --hard\" is\n> one, and \"git clean\" is another. There have been discussions and even\n> some patches about storing the lost in an \"undo log\", but nothing has\n> been merged.\n>\nSeems like a good idea. Are they ever gonna merge? If no, why? Or, it\nwill merge in next feature release.\n\n"},{"id":"381445","messageId":"20190828150530.GD14432@sigill.intra.peff.net","threadId":"51756","inReplyTo":"664344cb-f9e4-d4fc-fd14-620e3e10157a@disroot.org","subject":"Re: Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-08-28T15:05:30Z","receivedAt":"2019-08-28T15:05:33Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 27, 2019 at 10:42:03PM +0000, Vipul wrote:\n\n> Jeff King wrote:\n> > The usual philosophy in Git is not to bother the user with\n> > confirmations, but to allow recovery after a mistake.\n> > \n> \n> Well, always prompting for confirmation will be annoying for some people\n> specially who are mastered in git but, may be very useful feature for\n> beginner's to avoid them from making mistakes. May be, this feature will\n> be disabled by default and users have to set some config variable (like\n> other git-config variable for example help.autocorrect etc) in global\n> gitconfig file.\n\nSure, I think there's an argument to be made for confirmations (though I\npersonally would not want them). I was just describing what Git has now.\n\n> > Note that there _are_ some commands which are not reversible: mostly\n> > things that drop content from the working tree. So \"git reset --hard\" is\n> > one, and \"git clean\" is another. There have been discussions and even\n> > some patches about storing the lost in an \"undo log\", but nothing has\n> > been merged.\n> >\n> Seems like a good idea. Are they ever gonna merge? If no, why? Or, it\n> will merge in next feature release.\n\nI don't know the latest state. A quick search of the archive showed this\nas the latest version:\n\n  https://public-inbox.org/git/20181209104419.12639-1-pclouds@gmail.com/\n\n-Peff\n"},{"id":"381449","messageId":"CACsJy8CnaYqKSs7oCpCVSiVeferb9KJS6Fvu791BH8nBYKt6Jg@mail.gmail.com","threadId":"51756","inReplyTo":"20190828150530.GD14432@sigill.intra.peff.net","subject":"Re: Support for an interactive confirmation prompt when users can possibly lose their work like some UNIX commands","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2019-08-28T15:27:35Z","receivedAt":"2019-08-28T15:28:03Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Aug 28, 2019 at 10:05 PM Jeff King <peff@peff.net> wrote:\n> > > Note that there _are_ some commands which are not reversible: mostly\n> > > things that drop content from the working tree. So \"git reset --hard\" is\n> > > one, and \"git clean\" is another. There have been discussions and even\n> > > some patches about storing the lost in an \"undo log\", but nothing has\n> > > been merged.\n> > >\n> > Seems like a good idea. Are they ever gonna merge? If no, why? Or, it\n> > will merge in next feature release.\n\nIf people are interested in the backup-log thing below, they can\nreuse/refine the work or the idea from that, but I'm not going to push\nit (or anything else) for merging.\n\n> I don't know the latest state. A quick search of the archive showed this\n> as the latest version:\n>\n>   https://public-inbox.org/git/20181209104419.12639-1-pclouds@gmail.com/\n-- \nDuy\n"}]}