1

git flow任何时候只允许一个修补程序分支。所以而不是输入:

git flow hotfix finish hotfix_branch

我想创建一个使用唯一现有修补程序分支名称的别名。类似于以下伪代码:

[alias]
  fix-done = flow hotfix finish `git_fetch_branch_beginning_with_hotfix`

任何人都可以帮忙吗?谢谢。

更新:我正在使用 zsh。

4

3 回答 3

1

这个函数或多或少是从git-flow的源代码中提取的:

finish_current_hotfix_branch ()
{
  local hotfix_prefix=$(git config --get gitflow.prefix.hotfix)
  local hotfix_branches=$(echo "$(git branch --no-color | sed 's/^[* ] //')" | grep "^$hotfix_prefix")
  local first_branch=$(echo ${hotfix_branches} | head -n1)
  first_branch=${first_branch#$hotfix_prefix}
  git flow hotfix finish "$first_branch"
}

更新

似乎您必须将整个函数放在别名中。不好,但有效:

[alias]
  fix-done ="!_() { p=$(git config --get gitflow.prefix.hotfix); b=$(echo \"$(git branch --no-color | sed 's/^[* ] //')\" | grep \"^$p\"); f=$(echo ${b} | head -n1); f=${f#$p}; git flow hotfix finish \"$f\"; }; _"
于 2012-10-30T13:16:21.373 回答
1

这是执行 git flow hotfix finish 别名的另一种方法:

hf = "!_() { b=$(git rev-parse --abbrev-ref HEAD) && git co master && git pl && git co develop && git pl && git co $b && git rebase master && h=$(echo $b | sed 's/hotfix\\///g') && git flow hotfix finish -m 'new_tag' $h && git co master && git ps && git co develop && git ps && git ps --tags && git poo $b && git br -D $b;  }; _"
于 2016-02-01T22:50:55.440 回答
1

如果你运行 git flow AVH Edition 你可以这样做

$ git flow finish

当您在要完成的分支上时。这适用于修补程序、发布、功能和错误修复。

检查您是否运行 git flow AVH 版

$ git flow version
x.xx.x (AVH Edition)
于 2016-02-02T16:17:51.643 回答