You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在GitHub Desktop中丢弃未提交/未暂存变更而不移入回收站?Git替代方案是什么?

GitHub Desktop & Git: Discarding Changes Without Recycle Bin, Plus One-Click Workflows

Can GitHub Desktop discard changes without sending files to the recycle bin?

Unfortunately, GitHub Desktop doesn’t have a built-in option to skip the recycle bin when discarding changes. Its core design prioritizes safety by sending modified files to the recycle bin (or Mac’s Trash), so you can recover them if you change your mind. That said, if you need a faster, no-recycle-bin solution, using Git via the command line is your best bet (more on that below).

How to discard all uncommitted, unstaged changes with Git (one-command solution)

If you want to immediately discard all unstaged changes without sending anything to the recycle bin, run this command in your repository’s root directory:

git restore .

This command reverts all files in the current directory (and subdirectories) to their state at the last committed version. Heads up—changes are gone for good here, so double-check you don’t need any of the modified content first!

If you also have staged changes you want to discard, run these two commands in order:

git reset HEAD .  # Unstages all staged changes
git restore .      # Discards all unstaged changes

One-click discard all changes in GitHub Desktop (including Mac version)

The workflow is identical across Windows and Mac versions of GitHub Desktop:

  • Open GitHub Desktop and confirm you’re on the branch with the changes you want to discard.
  • Look at the left-hand "Changes" panel. At the top of this panel, you’ll see a Discard changes button.
  • Click the dropdown arrow next to the button, then select Discard all changes.
  • A confirmation popup will appear—click Discard Changes to finalize. All modified files will be moved to your system’s recycle bin (Mac: Trash) for recovery if needed.

This addresses your pain points for quick discards when switching branches with different .gitignore configs: the Git command line method skips the recycle bin entirely for speed, while the GitHub Desktop workflow keeps that safety net if you might need to revert the discard later.

内容的提问来源于stack exchange,提问作者Semi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 20:57:45