You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为git flow feature finish添加自定义命令或调整默认操作?

Great question! First off, you’re exactly right about what git flow feature finish {my_feature} does under the hood—those three commands are spot-on. Let’s break down your two asks:

1. Skipping the branch deletion step (no custom scripts needed!)

Git Flow actually has a built-in flag for this! Just add the --keep (or shorthand -k) parameter when running the finish command:

git flow feature finish -k {my_feature}

This will execute the first two steps (git checkout develop and git merge --no-ff feature/{my_feature}) but skip the git branch -d feature/{my_feature} part entirely. No need to mess with custom scripts or rewrite existing logic—this is native, out-of-the-box functionality.

2. Inserting commands between checkout and merge (no full logic replication needed)

Unfortunately, Git Flow doesn’t include a built-in hook or parameter to inject custom commands directly between the git checkout develop and git merge steps of the finish workflow. Its core sequence is hardcoded to run those steps in order without interruptions.

That said, you can avoid writing a full custom script or replicating Git Flow’s entire logic by splitting the finish process into manual steps:

  • First, run the checkout step yourself:
    git checkout develop
    
  • Execute your custom command(s) here (whatever you wanted to insert between checkout and merge)
  • Then, run the merge step—you can use Git Flow’s helper command to keep consistency with its default behavior:
    git flow feature merge {my_feature} --no-ff
    
    Or use the raw Git merge command if you prefer:
    git merge --no-ff feature/{my_feature}
    
  • Finally, if you still want to delete the feature branch, run:
    git branch -d feature/{my_feature}
    

This approach lets you interject your custom commands without rewriting Git Flow’s logic or building a separate script—you’re just breaking the automated finish into controlled manual steps where you dictate the flow.

内容的提问来源于stack exchange,提问作者Adam Baranyai

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 13:13:13