Skip to content

Discarding changes takes huge amounts of time #7155

Open

Description

@varkor

Even when discarding a few files at a time, the process can take upwards of ten seconds, when it should be instantaneous. (This has been a problem for a while, though qualitatively it seems to have gotten worse recently.)

There was a previous issue tracking this (#2629), but it has been closed, and this issue needs raised visibility, as it's an extreme source of frustration.

Here's a screen capture, but not that this problem occurs even for discarding one or two files.
discard-changes


I'm running GitHub Desktop 1.6.5 on macOS 10.12.6.

Activity

  1. shiftkey commented on Mar 25, 2019

    @shiftkey
    Member

    @varkor thanks for the feedback! We recently discussed this in #7015 and made a change in #7029 to show some progress while this work is happening. That should go out with the next beta, but please have a read of the changes and see if that makes sense to you.

    (This has been a problem for a while, though qualitatively it seems to have gotten worse recently.)

    I'd love to hear more details about this - I'm not sure we're measuring the "wall time" to complete these steps but maybe we could get that in to help us understand whether something has impacted this area.

    For reference, this is the hot path when discarding changes in the app:

    await queueWorkHigh(files, async file => {
    const foundSubmodule = submodules.some(s => s.path === file.path)
    if (file.status.kind !== AppFileStatusKind.Deleted && !foundSubmodule) {
    // N.B. moveItemToTrash is synchronous can take a fair bit of time
    // which is why we're running it inside this work queue that spreads
    // out the calls across as many animation frames as it needs to.
    this.shell.moveItemToTrash(
    Path.resolve(this.repository.path, file.path)
    )
    }

    We're limited by the Electron API shell.moveItemToTrash() which we use here to preserve the changes. It's a blocking API that only takes one file at a time, which limits how quickly we can move many files across.

  2. added
    more-info-needed
    on Mar 25, 2019
  3. varkor commented on Mar 25, 2019

    @varkor
    Author

    We recently discussed this in #7015 and made a change in #7029 to show some progress while this work is happening. That should go out with the next beta, but please have a read of the changes and see if that makes sense to you.

    I've been following that change, which is definitely an improvement from the point of view of feedback, but it's really the duration that is the problem.

    We're limited by the Electron API shell.moveItemToTrash() which we use here to preserve the changes. It's a blocking API that only takes one file at a time, which limits how quickly we can move many files across.

    I imagine that synchronous nature of the API isn't actually so much of a problem, because in general, discarding only a few file changes is more common. However, discarding is slow even for a single file, which suggests that there's some constant overhead here (either in the API or elsewhere).


    Perhaps it would be possible to have an option in the preferences that allows files to be removed directly, without going via the trash, if that's where the bottleneck occurs.

    I appreciate that it's hard to debug this if others are unable to reproduce this. I would like to investigate, but I'm not sure I'll have time in the near future.

  4. added
    investigation-needed
    on Mar 25, 2019
  5. removed
    more-info-needed
    on May 22, 2019
  6. shiftkey commented on May 22, 2019

    @shiftkey
    Member

    Dropping more-information-needed because I think we have enough information to go on.

    I also encountered this recently when I was stuck with 3000+ uncommitted changes, and I used this flow on macOS because it seemed simple enough but I got stuck for a couple of minutes waiting for it to complete.

    In the end I got impatient and closed the app because I wasn't sure how quickly it was progressing, and I didn't need to keep those changes in the trash.

  7. staabm commented on Dec 13, 2019

    @staabm

    just ran into this problems. tried to discard ~4300 files with changes.

    all my 4 CPU core were satured, the whole machine got slow. it took almost 5 minutes to complete -> usability nightmare

    looking into the task manager while waiting for it you can see a lot of git-processes getting spawned and go away.. I guess its one process per file beeing discarded.

    running GH Desktop 2.2.4 on Windows10x64 with latest windows updates

  8. staabm commented on Feb 11, 2020

    @staabm

    just discarded ~15.000 files... took ~20 minutes to complete.. the workstation was nearly frozen during this process

  9. 3ygun commented on May 12, 2020

    @3ygun

    As @staabm also mentioned for large sets of file discards it does per file deletion/removal for some reason instead of just git rming the entire file. Example case:

    1. npm install to make your giant .node_modules/ folder
    2. Then because you want to save it to test a change rename it to like .node_modules_clone/ (which isn't covered in your .gitignore)
    3. Say you're done with messing with this node module stuff so you open GitHub Desktop and have 15K "changed" files now
    4. If you use the GitHub desktop discard these get removed 1 by 1. BUT git status correctly lists that it's just a new folder so you could delete it all at once instead

    Not a huge priority for me but was definitely strange behavior as I force stopped it on MacOS 7K files and 10 minutes in and proceeded to rm -rf the rest in 5 seconds .

    Was on:

    • GitHub Desktop 2.4.3
    • MacOS Mojave 10.14.6
  10. cschreib-ibex commented on Sep 4, 2020

    @cschreib-ibex

    This has gotten much worse for me recently. Discarding a single file now takes about 5-10 seconds, no matter how small the file.
    Github desktop 2.5.4, Windows 10 x64.

  11. added
    performance
    on Sep 23, 2020
  12. ptkdev commented on Mar 2, 2021

    @ptkdev

    Same problem with 2.6.2 on linux and mac os.

  13. AdityaSavara commented on Nov 8, 2021

    @AdityaSavara

    I have a question / suggestion. In both the previous thread and this thread, the attitude seems to be "Does this happen often in your development?" My answer is "yes, the way I do things during testing, for better or worse, does include routine discarding of all changes"

    I have an alternative question which I would say is a better question... do people ever need to retrieve their discarded changes often? I don't think they do. I don't see why they should be sent to recycle bin. Why not just do a simple delete and let that be the end of it? it's hard for me to imagine someone discarding all changes unintentionally.

    Or, if if that is a concern, perhaps, give us a warning popup. I (and I think the others) would much rather have a warning popup followed by immediate delete rather than a few minutes of waiting for 100 files to delete (for me this waiting is frustrating, and it seems to be for others, also).

    It's not even obvious to me why this should be a delete. If we are discarding changes, to me that is like reversing a diff. I would expect github to simply overwrite my files using the files from the last commit.

    Another option: have the pop up give us the option "Permanent Discard" vs "Recycle/Trash" then we could click the one we want. And those of us who want a fast delete will start clicking "Permanent". This extra click will be worth it for those of us who want fast discards. In fact, I would even prefer that compared to sending to recycle bin!

    Note: there can even be a checkbox for "remember my choice" / "apply this choice to all future discards"

  14. Monsoonexe commented on Mar 29, 2022

    @Monsoonexe

    Still a problem in 2.9.12. Discarding 12 changes (<5MB) can take on the scale of 30 minutes

  15. ShaMan123 commented on Sep 16, 2022

    @ShaMan123

    +1 on windows 10
    The problem is much worse if .gitignore is part of the discarded changes.
    I presume that once the .gitignore file is deleted from disk the repo refreshes it's tracking state but doesn't have a .gitignore until the process finishes.... So things boil with node_modules for example.
    Am I correct?

  16. 1 remaining item

  17. AdityaSavara commented on Feb 12, 2023

    @AdityaSavara

    @Mixarar

    Same thing, discarding 5000 files took around 2-2.5 hours to complete on windows 10 Hardware: AMD EPYC 7543P 32 cores 16Gb of DDR4 RTX A4500

    Which version number of the app are you using? The problem has gone away for me.

  18. aminya commented on Sep 22, 2023

    @aminya
    Contributor

    I have the same issue. I don't know what GitHub Desktop is doing that takes so much time, but the following is instant:

    git reset HEAD && git clean -fd
    

    Using Version 3.3.1-linux1 (x64)

  19. firatesmer commented on Sep 27, 2023

    @firatesmer

    I have the same issue. Discarding the changes is taking too much time.
    Windows 11 22621.2283
    GitHub Desktop 3.3.3

  20. ShaMan123 commented on Sep 27, 2023

    @ShaMan123

    I am about to ditch github desktop
    Too many issues including this major problem

  21. misternebula commented on Jan 16, 2024

    @misternebula

    Trying to discard 6k files, taking over an hour so far. No idea if it's actually doing anything

  22. aminya commented on Jan 16, 2024

    @aminya
    Contributor

    I fixed the issue in this pull request last year September. However, the maintainers have not merged it yet.
    #17436

  23. steveward commented on May 3, 2024

    @steveward
    Contributor

    Reported in #18548.

  24. nedredmond commented on Dec 5, 2024

    @nedredmond

    Currently waiting for it to discard almost 20k files. I wish there was a way to stop the process so that I could use git commands instead.

  25. blackletum commented on May 14, 2025

    @blackletum

    I fixed the issue in this pull request last year September. However, the maintainers have not merged it yet. #17436

    I think you should re-submit it, since they gave you all of 2 weeks to reply and then closed the request.

    Your addition would be very appreciated.

  26. AdityaSavara commented on May 14, 2025

    @AdityaSavara

    The changes that aminya made are shown as diffs:

    https://github.com/desktop/desktop/pull/17436/files
    https://github.com/shiftkey/desktop/pull/934/files

    So (a) one can try to do this for aminya, (b) one can even fork aminya's branch and then synchronize to newest branch before making a pull request.

    The developers did give feedback. So I would say this is now back on the community of users. Additionally, I find some amusement here, because just as aminya tried to "save" the developers work, in my view it is now incumbent on the community to save aminya from doing work :)

    It seems that there must be professional programmers who are bothered by this issue, so one of them should be able to do the process I just described, above.

  27. SolvalouArt commented on Feb 1, 2026

    @SolvalouArt

    Still having this problem in 2026. It takes 20 entire minutes every time i want to discard changes. This is a major issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigation-neededperformanceskip-pitch

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions