是否有一个Git命令可以恢复工作树和索引中所有未提交的更改,并删除新创建的文件和文件夹?
当前回答
从Git帮助:
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
其他回答
从Git帮助:
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
您可以执行以下两条命令:
# Revert changes to modified files.
git reset --hard
# Remove all untracked files and directories.
# '-f' is force, '-d' is remove directories.
git clean -fd
安全而漫长的路:
Git分支要删除 Git签出删除 Git添加。 “我做了件坏事,对不起” Git检查开发 git分支-D删除
我认为你可以使用以下命令:git reset——hard
git clean -fd
没有帮助,新的文件仍然存在。我完全删除了所有工作树,然后
git reset --hard
在“https://stackoverflow.com/questions/673407/how-do-i-clear-my-local-working-directory-in-git/673420#673420”中添加-x选项的建议:
git clean -fdx
注意-x标志将删除所有被Git忽略的文件,所以要小心(参见我引用的答案中的讨论)。
推荐文章
- GitHub -未能连接到GitHub 443 windows/连接到GitHub失败-无错误
- 如何使Eclipse/EGit在更新后识别现有的存储库信息?
- 撤销意外git隐藏pop
- 我怎么能让詹金斯CI与Git触发器推到主人?
- Git:哪个是分支的默认配置远程?
- 如何从拉请求中删除提交
- 如何用分发文件发布npm包?
- 跟踪在GitHub上创建的一个新的远程分支
- 没有空格的合并会产生冲突
- 如何使用refspec将Git标记推到分支?
- 如何使用Git向远程存储库进行初始推送?
- 将文件的当前工作副本与另一个分支提交的副本区别对待
- 配置Git接受特定https远程的特定自签名服务器证书
- 如何将一个特定的提交从一个分支合并到Git中的另一个分支?
- 通过SSH配置Git登录一次