Git 流 : Do you have to manually delete the feature branches from remote after finishing the feature?

标签 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

问题:

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

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

我做错了什么吗?

最佳答案

如果您曾经做过 git push origin(feature 在本地 check out ),请知道当前的默认推送策略是 default。
这意味着 ( git config man page )

matching - push all branches having the same name in both ends.

但是:

This is currently the default, but Git 2.0 will change the default to simple.

upstream - push the current branch to its upstream branch.
With this, git push will update the same remote ref as the one which is merged by git pull, making push and pull symmetrical.

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

(政策的变化是in discussion for the past few months)

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

git push origin :feature

git flow 的唯一原因如果您在此过程中的任何时候都没有指定标志“fetch”,则不会删除功能分支。 See sources .

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

这意味着你应该做一个

git flow feature finish -F new_feature

我们的想法是先获取并确保在删除之前,其他 贡献者没有向 GitHub 上的 new_feature 添加新的演变。

关于Git 流 : Do you have to manually delete the feature branches from remote after finishing the feature?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11150810/

相关文章:

git - 如何避免 git rebase 杀死 merge 提交?

version-control - 用于清除 Git Bash 屏幕(包括输出缓冲区)的命令

css - Git add -patch...但忽略空格更改

git - 现有的 Emacs 模块缺少哪些功能可以与 git 一起使用?

macos - gcloud init 因用户名/密码无效而失败

svn - 解决svn中的属性冲突

github - 尝试合并分支时执行 Github Action

Github:将更改从一个仓库推送到另一个仓库

git:osxkeychain 凭据助手默默地无法记住用户名/密码

android - 如何在git上添加proguard映射文件(在gitignore、Android Studio中排除)