python - git-clean 与 GitPython

标签 python git gitpython git-clean

有什么方法可以使用 GitPython 执行类似 git clean -d -x -f 的操作吗?

我需要重置工作目录并希望在不删除整个文件夹(.git 除外)的情况下删除所有未版本控制的文件并再次 check out 。

最佳答案

你可以通过在 gitpython 中直接使用 git 命令来变通

git = repo.git
git.clean('-xdf')

关于python - git-clean 与 GitPython,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28569923/

相关文章:

python - 如何使用 pika 通过 Python 客户端连接到 RabbitMQ 集群?

python - SDL2 错误 : "Unable to load image <default.png>" when freezing kivy application using pyinstaller

python - 如何使用 python (pyGithub) 获取 github pull request 所有审阅者

git - 将过滤器条目添加到 git 配置文件

git - git 中 repo 特定的忽略文件

azure-functions - Azure 函数 - 应用服务计划 - 安装 git 包

python - gitpython 列出所有存储库

python - 使用 gitpython 编辑提交

python - 根据url从WARC文件中检索记录

git - 如何恢复删除历史记录的分支的 git 历史记录?