68 个 登录

九库查询/Git 命令速查/git restore

git restore

丢弃工作区里某个文件的改动(Git 2.23+)

Git 命令速查 更新 2026-11-16
分组
撤销与回退
命令
git restore
示例
git restore src/main.go

老写法是 git checkout -- <file>。这会真的丢掉未提交内容,先确认文件没别的活。

数据来源:Git 官方文档整理。内容存于数据库,更新日期 2026 年 11 月 16 日。