撤消多个文件和文件夹“git add”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18424943/
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
Undo multiple file and folder 'git add'
提问by hopper
I executed
我执行了
git add .
and now I want to revert that git add. How can I accomplish that?
现在我想恢复那个 git add。我怎样才能做到这一点?
回答by dahlbyk
git reset
(which is equivalent to git reset HEAD
) will un-add
(more commonly "unstage") all files.
git reset
(相当于git reset HEAD
)将取消add
(更常见的是“取消暂存”)所有文件。
In Git, revert
is used for undoing an existing commit (typically a commit that happened a while ago, or has been shared with others). If your commit has not yet been shared with others, there are ways to "rewrite" recent history such that you can pretend the changes you want to revert never happened in the first place.
在 Git 中,revert
用于撤消现有提交(通常是前一段时间发生的提交,或已与他人共享)。如果您的提交尚未与其他人共享,则有多种方法可以“重写”最近的历史记录,这样您就可以假装要还原的更改从未发生过。
回答by Jordan McCullough
You can unstage all snapshots with git reset HEAD
or selectively unstage paths with git reset HEAD -- <filepath>
.
您可以使用git reset HEAD
或有选择地取消暂存路径的所有快照git reset HEAD -- <filepath>
。