git add -p --ignore-submodules? [英] git add -p --ignore-submodules?

查看:246
本文介绍了git add -p --ignore-submodules?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 git add --patch 时是否可以忽略脏子模块?

Is there a way to ignore dirty submodules when using git add --patch?

我已设置 ignore =脏,如此处所述。这似乎仅在 git status git diff 下起作用。我喜欢 git add -p 。每当我想添加一个小的更改时,都不得不跳过10个肮脏的子模块,这让我感到沮丧。

I've set ignore = dirty as explained here. This seems to only work with git status and git diff. I love git add -p. Having to skip through 10 dirty submodules every time I want to add a small change frustrates me.

我还不太清楚 git add- i ,但看起来它以相同的方式处理脏子模块。

I haven't quite figured out git add -i yet, but it looks like it handles dirty submodules the same way.

推荐答案

已默默添加引用Clint的说法,忽略子模块更新似乎很危险。

Having add silently ignore submodule updates seems, to quote Clint, tooooo dangerous.

我不知道如何使用add --patch来做,但是我可以通过add --edit和vim键盘映射来实现非常接近:

I don't know how to do it with add --patch, but I can get pretty close with add --edit and a vim keymapping:

map <Leader>\x :%!sed '/^diff --git/\!{H;$\!d};x;1{$\!d;x};/\nindex[^\n]*160000\n/d'<CR>

而将映射 \\x 消除所有子模块更新功能。其中的 \!是vim特定的爆炸转义符,请删除这些反斜杠以在其他地方使用sed。

while will map \\x to eliminate all submodule update hunks. The \!s in that are vim-specific bang escapes, strip those backslashes to use the sed elsewhere.

这篇关于git add -p --ignore-submodules?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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