删除 git commit 的所有文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4190584/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove all files for git commit?
提问by Mohit Deshpande
Possible Duplicate:
Undo “git add”?
可能的重复:
撤消“git add”?
I made the mistake of running:
我犯了运行的错误:
git add .
Which added important things such as .bashrc. Even though I run:
其中添加了重要的内容,例如 .bashrc。即使我运行:
git rm .
When I run:
当我运行时:
git push project master
Everything still is added. I've even reinstalled git, but I am still pestered by this. A solution I found was to start over and remove all the files from the commit. Are there any other things I could do to remove all the files from the commit?
一切都还在添加中。我什至重新安装了 git,但我仍然对此感到困扰。我找到的一个解决方案是重新开始并从提交中删除所有文件。我还能做些什么来从提交中删除所有文件?
回答by David Winslow
You can use git reset
to unstage changes, or even git reset --hard HEAD~
to blow away the most recent commit (careful with that one, it will not even keep your changes around.)
您可以使用git reset
unstage 更改,甚至删除git reset --hard HEAD~
最近的提交(小心那个,它甚至不会保留您的更改。)
回答by ThiefMaster
Use git reset
.
使用git reset
.