Git 流是否删除远程服务器上的分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11151623/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:59:47  来源:igfitidea点击:

Does Git flow deletes branch on remote server?

gitgit-flow

提问by Paritosh Singh

I am using git along with git flow. Here git flow has a developbranch. Whenever i need to start feature i type

我正在使用 git 和git flow。这里 git flow 有一个develop分支。每当我需要启动功能时,我都会输入

git flow feature start new

a new branch feature/newis created. Then i do the changes and committhem using

feature/new创建了一个新分支。然后我做的修改,并提交使用它们

git push origin feature/new

After comitting the changes I finish feature using

提交更改后,我使用

git flow feature finish new

it deletesfeature/newbranch locally. Now I am switched to develop branch by git flowand I again type

它在本地删除feature/new分支。现在我切换到通过 git flow 开发分支,我再次输入

git push origin develop

which make changes to remote server developbranch

对远程服务器develop分支进行更改

If I type git branch -a, the new branch got deleted from the local but it is there on the server with name remotes/origin/feature/new

如果我输入git branch -a,新分支会从本地删除,但它在服务器上有名字remotes/origin/feature/new

Does git flow delete branches on remote serverwhich are deleted at my local machine?

git flow 是否删除远程服务器上的分支,这些分支在我的本地机器上被删除?

Please tell me if I am making some mistake.

如果我犯了一些错误,请告诉我。

采纳答案by Stefan

Looking at the sourceit seems that the remote feature branch is deleted only if you call git flow feature finishwith -F.

查看源代码,似乎只有当您git flow feature finish使用-F.

However, this fetches the remote before finishing the feature. From the docs:

但是,这会在完成功能之前获取遥控器。从文档

-Ffetch from $ORIGIN before performing finish

-F在执行完成之前从 $ORIGIN 获取

Otherwise you can delete the remote branchmanually with:

否则,您可以使用以下命令手动删除远程分支

git push origin :feature/new

回答by Peter van der Does

May I suggest using the git-flow AVH Edition.

我可以建议使用 git-flow AVH 版。

Like Stefan said, the original version only deletes the remote branch when you use -F, which is kinda strange. The AVH Edition fixes this quirky behavior, it will always delete the local and remote feature branch on a finish, unless you specify either

就像 Stefan 说的,原来的版本只在你使用时删除远程分支-F,这有点奇怪。AVH 版本修复了这个古怪的行为,它总是会在完成时删除本地和远程功能分支,除非您指定

  • --keep, which keeps the local and remote.
  • --keeplocal, which keeps the local, but deletes the remote.
  • --keepremote, which keeps the remote, but deletes the local.
  • --keep,保持本地和远程。
  • --keeplocal,保留本地,但删除远程。
  • --keepremote,保留远程,但删除本地。

You can find git-flow AVH Edition on github.

您可以在github上找到 git-flow AVH 版。

回答by David Prieto

What I had to do:

我必须做的:

git flow feature delete -f name_feature

The -f is necessary if there are changes inside the feature branch.

如果功能分支内有更改,则 -f 是必需的。

git push origin --delete feature/name_feature

That is to delete the remote branch as well.

那就是删除远程分支。