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

Yug*_*dle 9 git version-control github 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
Run Code Online (Sandbox Code Playgroud)

问题:

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

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

难道我做错了什么 ?

Von*_*onC 6

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

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

但:

这是目前的默认设置,但Git 2.0会将默认设置更改为simple.

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

(因为feature在GitHub中最初没有上游分支,所以不会被推送)

(政策的变化正在讨论过去几个月)

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

git push origin :feature
Run Code Online (Sandbox Code Playgroud)

如果你没有在进程中的任何时候指定一个标志' ',那么git flow就不会删除一个功能分支的唯一原因fetch.见资料来源.

# delete branch
if flag fetch; then
  git push "$ORIGIN" ":refs/heads/$BRANCH"
fi
Run Code Online (Sandbox Code Playgroud)

这意味着你应该做的

git flow feature finish -F new_feature
Run Code Online (Sandbox Code Playgroud)

我的想法是首先获取并确保其他贡献者在删除它之前没有new_feature在GitHub上添加新的进化.