简体   繁体   English

如何使用 python 从更新中排除 git 子模块?

[英]How do I exclude a git submodule from update using python?

When I run the following command from a bash shell, it works as expected, and updates all submodules except the one indicated as to-be-ignored:当我从 bash shell 运行以下命令时,它按预期工作,并更新所有子模块,但指示为要忽略的子模块除外:

git -c submodule."MySub".update=none submodule update --init --recursive

However, when I attempt the same thing in python using subprocess, MySub gets updated as well:但是,当我使用 subprocess 在 python 中尝试同样的事情时,MySub 也会更新:

cmd = ['git', '-c', 'submodule."MySub".update=none', 'submodule', 'update', '--init', '--recursive']

subprocess.call(cmd)

Do I need to format the 'submodule."MySub".update=none' argument differently?我是否需要以不同的方式格式化'submodule."MySub".update=none'参数?

In bash you can use the quotes for special characters in the submodule path (slashes for example), but in python you don't need them.在 bash 中,您可以对子模块路径中的特殊字符使用引号(例如斜杠),但在 python 中您不需要它们。 Try it with:试试看:

'submodule.MySub.update=none'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM