如何从git临时区域删除文件? [英] How to remove files from git staging area?

查看:84
本文介绍了如何从git临时区域删除文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的本地仓库中对我的一些文件进行了更改,然后我做了 git add -A ,我认为在暂存区域中添加了太多文件。我怎样才能从暂存区域中删除所有文件?

I made changes to some of my files in my local repo, and then I did git add -A which I think added too many files to the staging area. How can I delete all the files from the staging area?

完成后,我将手动执行 git addfilename

After I do that, I'll just manually do git add "filename".

推荐答案

您可以使用

You can unstage files from the index using

git reset HEAD -- path/to/file

就像 git add 一样,您可以通过目录等等递归取消保存文件,所以要一次性取消所有内容,请从存储库的根目录运行:

Just like git add, you can unstage files recursively by directory and so forth, so to unstage everything at once, run this from the root directory of your repository:

git reset HEAD -- .

另外,为了将来的参考, git status 会告诉你需要运行的命令将文件从一个状态移动到另一个状态。

Also, for future reference, the output of git status will tell you the commands you need to run to move files from one state to another.

这篇关于如何从git临时区域删除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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