如何撤销未提交的更改,包括文件和文件夹?

19 浏览
0 Comments

如何撤销未提交的更改,包括文件和文件夹?

有没有一条Git命令可以撤消工作树和索引中的所有未提交更改,并删除新创建的文件和文件夹?

admin 更改状态以发布 2023年5月21日
0
0 Comments

如果您只想在当前工作目录中恢复更改,请使用

git checkout -- .

在此之前,您可以列出将被还原的文件,而不实际采取任何操作,只是为了检查会发生什么,使用:

git checkout --

0
0 Comments

你可以运行下列两个命令:

# Revert changes to modified files.
git reset --hard
# Remove all untracked files and directories.
# '-f' is force, '-d' is remove directories.
git clean -fd

0