与 git add -p 相反

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13065599/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 07:40:58  来源:igfitidea点击:

Opposite of git add -p

git

提问by Micha Wiedenmann

Is there an opposite to git add -p? Sometimes I add a chunk by mistake and want to remove it from the index (which I do by git reset; git add -pand adding all the good chunks again). An git remove-from-index -pcommand would be helpful in this case.

有反义词git add -p吗?有时我错误地添加了一个块并想从索引中删除它(我这样做git reset; git add -p并再次添加所有好的块)。一个git remove-from-index -p命令是在这种情况下有帮助。

回答by greg0ire

From the git-reset man page:

从 git-reset 手册页:

This means that git reset -p is the opposite of git add -p

                                  ^
                                  |
                        exact match of your post title

这意味着 git reset -p 与 git add -p 相反

                                  ^
                                  |
                        exact match of your post title

回答by crispyduck

Unfortunately, there is no direct opposite command. What you are looking for is to "unstage" a file (git addhaving staged the file for commit). Please see this answer for more details:

不幸的是,没有直接相反的命令。您正在寻找的是“取消git add暂存”文件(已暂存文件以进行提交)。有关更多详细信息,请参阅此答案:

Why are there 2 ways to unstage a file in git?

为什么有两种方法可以在 git 中取消暂存文件?