gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-29 12:47:45 27 4
gpt4 key购买 nike

我是 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com