• Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • None
    • General
    • None
    • mac os x 10.9.1
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      It would be good if 'discard' operations where undoable.

      I was just preparing some files to commit, and accidentally hit the 'discard' button when I meant to hit 'discard hunk', and appear to have now permanently lost my changes (well, until I go delving through time machine).

      Apparently I'm not the first person to do this:

      http://stackoverflow.com/questions/11418429/how-to-undo-discard-if-not-committed

      If it's not possible/easy to undo, leaving a copy of the file somewhere it could be recovered from manually would be useful (unless that already happens and I just don't know where to look!).

            [SRCTREE-2090] Allow discarding file to be undone

            I would vote for this to be added as well πŸ™πŸ»

            attendance-terminal added a comment - I would vote for this to be added as well πŸ™πŸ»

            Yes, this is a very nice feature and I think also easy to implement (just create a temp file and move to the trash bin). It can save my mental sanity.

            inmeta-mauro-bertoli added a comment - Yes, this is a very nice feature and I think also easy to implement (just create a temp file and move to the trash bin). It can save my mental sanity.

            Yup just did this lost days worth of work buying git kracken now. You all obviously don't care!!!!!! Go to hell 

            Jeremy Wilson added a comment - Yup just did this lost days worth of work buying git kracken now. You all obviously don't care!!!!!! Go to hell 

            I'm not sure I'm in the right bug.  I had 4 new files (uncommitted) and one committed file that had changes in it.  I mistakenly chose "right-click files->remove." on all of them.  I was able to find the 4 files that hadn't been committed in the trash, but the one file already in the depo was nowhere to be found.

            I'm not sure if the previous discussions made this clear, but I don't understand why that file couldn't have also been moved to the trash.

            David Clancy added a comment - I'm not sure I'm in the right bug.  I had 4 new files (uncommitted) and one committed file that had changes in it.  I mistakenly chose "right-click files->remove." on all of them.  I was able to find the 4 files that hadn't been committed in the trash, but the one file already in the depo was nowhere to be found. I'm not sure if the previous discussions made this clear, but I don't understand why that file couldn't have also been moved to the trash.

            @kieran - this is an issue when you have 'discard hunk' and 'discard link' in the same contextual (right click) menu that pops up when you click on line! So when you THINK you are clicking "discard line" you don't really think too much about the pop up appearing because you meant to discard something and then suddenly an entire chunk of your code is gone forever when you meant to simply discard the deletion of an empty line!

            lindsayannb added a comment - @kieran - this is an issue when you have 'discard hunk' and 'discard link' in the same contextual (right click) menu that pops up when you click on line! So when you THINK you are clicking "discard line" you don't really think too much about the pop up appearing because you meant to discard something and then suddenly an entire chunk of your code is gone forever when you meant to simply discard the deletion of an empty line!

            KieranA added a comment -

            Hey Joseph,

            Good idea - you could have another button the dialog, a checkbox even, to create a stash of the changes. I can see many cases where people want to discard changes. There's a few routes we can take here, it's choosing the simplest path for the user.

            Thanks very much

            KieranA added a comment - Hey Joseph, Good idea - you could have another button the dialog, a checkbox even, to create a stash of the changes. I can see many cases where people want to discard changes. There's a few routes we can take here, it's choosing the simplest path for the user. Thanks very much

            Hi Kieran,

            Yep, I completely agree that it's absolutely clear. The issue is I was expecting a dialogue (as the one for discard hunk is very similar iirc), so my brain was on autopilot and accepted the dialogue before actually reading it.

            I understand it's a tricky one.

            Just a random thought (no idea how easy this is, I'm unfamiliar with git internals): would it be possible to have "discard" instead create a stash automatically? Probably that would need to be configurable (and perhaps on by default).

            Joseph Heenan added a comment - Hi Kieran, Yep, I completely agree that it's absolutely clear. The issue is I was expecting a dialogue (as the one for discard hunk is very similar iirc), so my brain was on autopilot and accepted the dialogue before actually reading it. I understand it's a tricky one. Just a random thought (no idea how easy this is, I'm unfamiliar with git internals): would it be possible to have "discard" instead create a stash automatically? Probably that would need to be configurable (and perhaps on by default).

            KieranA added a comment -

            Hey Joseph,

            This one gets raised a lot. We do provide a confirmation to 'discard' your changes rather than 'Move to trash' or the likes. It quite literally performs a Git operation, and the Git operation doesn't have any undo/redo management in it. Once that operation has occurred there is no way to get it back.

            A confirmation dialog presented states "Are you sure you want to discard your changes to the selected files?" when you hit 'Discard', so we're not sure how we can be any clearer than this.

            The only other option is for us to provide a backup system in which dumps a diff of the changeset somewhere - but this is a very large and complicated thing to do.

            I'll keep this on the list so we can take it into consideration.

            Cheers

            KieranA added a comment - Hey Joseph, This one gets raised a lot. We do provide a confirmation to 'discard' your changes rather than 'Move to trash' or the likes. It quite literally performs a Git operation, and the Git operation doesn't have any undo/redo management in it. Once that operation has occurred there is no way to get it back. A confirmation dialog presented states "Are you sure you want to discard your changes to the selected files?" when you hit 'Discard', so we're not sure how we can be any clearer than this. The only other option is for us to provide a backup system in which dumps a diff of the changeset somewhere - but this is a very large and complicated thing to do. I'll keep this on the list so we can take it into consideration. Cheers

              Unassigned Unassigned
              ec853f785405 Joseph Heenan
              Votes:
              14 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated: