在上次在git中提交后重置所有更改 [英] Reset all changes after last commit in git

查看:100
本文介绍了在上次在git中提交后重置所有更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在上次提交后撤消对目录所做的更改,包括删除添加的文件,重置修改​​的文件以及添加删除的文件?

首先重置更改

  git reset HEAD --hard 

然后清除未跟踪的所有内容。如果您想保留由于 .gitignore 而未跟踪的文件,请注意此命令。

  git clean -fd 


How can I undo every change made to my directory after the last commit, including deleting added files, resetting modified files, and adding back deleted files?

解决方案

First reset the changes

git reset HEAD --hard

then clean out everything untracked. If you want to keep files that are not tracked due to .gitignore, be careful with this command.

git clean -fd

这篇关于在上次在git中提交后重置所有更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆