首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在合并时使用GitPython的"--no-ff --no-commit“?

问如何在合并时使用GitPython的"--no-ff --no-commit“?
EN

Stack Overflow用户
提问于 2020-06-24 23:29:04
回答 1查看 405关注 0票数 0

当我使用命令行git merge与--no-ff --no-commit一起使用时,效果很好。但是使用GitPython我无法做到这一点。

可能是我找不到正确的文档或论坛来使用GitPython进行下面的等效操作。

我错过了什么吗?

命令行:

代码语言:javascript
复制
git merge --no-ff --no-commit "<TAG Name> or <Feature branch>"

GitPython:

代码语言:javascript
复制
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给出以下错误

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2020-07-24 16:26:57

这应该是可行的

代码语言:javascript
复制
git.merge('args', no_ff=True)

将'args‘替换为您的参数,如您的分支...

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62558633

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档