How to revert uncommitted changes including files and folders?
是否有一个git命令来恢复工作树和索引中的所有未提交的更改,并删除新创建的文件和文件夹?
你可以运行这两个命令:
# Revert changes to modified files.
git reset --hard
# Remove all untracked files and directories. (`-f` is `force`, `-d` is `remove directories`)
git clean -fd
If you want to revert the changes only in current working directory, use
git checkout -- .
And before that, you can list the files that will be reverted without actually making any action, just to check what will happen, with:
git checkout --
Use "git checkout -- ..." to discard changes in working directory
git checkout -- app/views/posts/index.html.erb
or
git checkout -- *
removes all changes made to unstaged files in git status eg
modified: app/controllers/posts.rb
modified: app/views/posts/index.html.erb
链接地址: http://www.djcxy.com/p/9820.html
上一篇: 你如何隐藏未跟踪的文件?
下一篇: 如何恢复未提交的更改,包括文件和文件夹?