Git Flow :完成功能后是否必须从远程手动删除功能分支



我是GITGIT-Flow的新手。[ 在我的 python-django 项目中 ]

我做了什么:

git flow feature start new_feature
# perform some commits on the feature/new_feature branch
git push origin feature/new_feature
git flow feature finish new_feature
# I suppose that merges feature/new_feature to develop and deletes feature/new_feature
git push origin develop # Pushes the new changes to remote

问题:

  • 功能/new_feature分支似乎在我的本地计算机上被删除了。
  • 但是在github[我的远程命名原点]上,我可以看到分支功能/new_feature。
  • 我很困惑,它不应该显示已删除的分支。
  • 我四处寻找解决方案 - 但他们说你应该手动删除远程它们,这似乎不符合git flow的抽象

那么,你们每次使用git-flow时都必须从所有遥控器中删除所有功能分支吗?

我做错了什么吗?

如果您曾经执行过git push originfeature在本地签出),请知道当前的默认推送策略是 default.
这意味着(git config手册页)

matching - 推送端具有相同名称的所有分支。

但:

这是当前默认设置,但 Git 2.0 会将默认值更改为 simple

upstream - 将当前分支推送到其上游分支.
有了这个,git push 将更新与 git pull 合并的远程引用相同的远程引用,使推送和拉取对称。

(由于feature最初在 GitHub 中没有上游分支,因此不会被推送)

(过去几个月一直在讨论政策变化)

所以现在,如果你确实将feature分支推送到 GitHub,然后在本地将其合并到 develop 并推送develop,你需要从 GitHub 中删除你的功能分支:

git push origin :feature

如果您在过程中的任何时候都没有指定标志 ' fetch',git flow 不会删除功能分支的唯一原因。见资料来源。

# delete branch
if flag fetch; then
  git push "$ORIGIN" ":refs/heads/$BRANCH"
fi

这意味着你应该做一个

git flow feature finish -F new_feature

这个想法是先获取并确保没有新的演变被其他贡献者添加到 GitHub 上的new_feature,然后再删除它。

最新更新