python-3.x - 合并时如何使用 GitPython 使用“--no-ff --no-commit”?
问题描述
当我使用命令行 git merge 和 --no-ff --no-commit 工作正常。但是使用 GitPython 我无法做到。
可能是我没有为使用 GitPython 的以下等效操作找到正确的文档或论坛。
我错过了什么吗?
命令行:
git merge --no-ff --no-commit "<TAG Name> or <Feature branch>"
GitPython:
print(f"Merging from tag '{input_tag}' into 'master'...")
repo = Repo(constants.git_clone_local_path)
repo.git.checkout('master')
repo.git.pull()
repo.git.merge(f'--no-ff --no-commit {input_tag}')
# repo.git.merge(f'{input_tag}', no_ff=True)
print(repo.git.status())
print('Done')
Python给出以下错误
cmdline: git merge --no-ff --no-commit test_tag
stderr: 'error: unknown option `no-ff --no-commit test_tag'
usage: git merge [<options>] [<commit>...]
or: git merge --abort
or: git merge --continue
-n do not show a diffstat at the end of the merge
--stat show a diffstat at the end of the merge
--summary (synonym to --stat)
--log[=<n>] add (at most <n>) entries from shortlog to merge commit message
--squash create a single commit instead of doing a merge
--commit perform a commit if the merge succeeds (default)
-e, --edit edit message before committing
--cleanup <mode> how to strip spaces and #comments from message
--ff allow fast-forward (default)
--ff-only abort if fast-forward is not possible
--rerere-autoupdate update the index with reused conflict resolution if possible
--verify-signatures verify that the named commit has a valid GPG signature
-s, --strategy <strategy>
merge strategy to use
-X, --strategy-option <option=value>
option for selected merge strategy
-m, --message <message>
merge commit message (for a non-fast-forward merge)
-F, --file <path> read message from file
-v, --verbose be more verbose
-q, --quiet be more quiet
--abort abort the current in-progress merge
--quit --abort but leave index and working tree alone
--continue continue the current in-progress merge
--allow-unrelated-histories
allow merging unrelated histories
--progress force progress reporting
-S, --gpg-sign[=<key-id>]
GPG sign commit
--overwrite-ignore update ignored files (default)
--signoff add Signed-off-by:
--verify verify commit-msg hook
解决方案
这应该工作
git.merge('args', no_ff=True)
用你的论点替换'args',比如你的分支......
推荐阅读
- ios - watchOS 6 WKInterfaceImage 在释放时崩溃
- java - 谷歌云调试器线程“无法继续”
- android - 图像从相机旋转捕获
- c - Scons:自定义默认构建器
- javascript - 如何使用jquery DataTable附加与上述行相同模式的空行
- html - 从整体中删除 3 列
- python - ValueError:无法将字符串转换为浮点数:'0:35:00'
- angular - 通过以编程方式更新,在角度 7 中看不到任何带有 echart 的图表
- android - Appium 与 Android Enterprise(工作配置文件)
- android - 如何重新启用开发者选项