我如何安全地删除远程git分支? [英] How do I safely delete a remote git branch?

查看:127
本文介绍了我如何安全地删除远程git分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要在git中删除本地分支,我使用 git branch -d ,但是如何安全地删除远程分支?



只有当远程分支合并到当前分支时,我才想将其删除。

答案部分在这里覆盖:
$ b已经合并成master了$ b

尽管该文章适用于本地分支机构,但您可以找到合并或不使用的远程分支机构



一旦你f发现特定的远程分支已经合并(即,它出现在输入 git branch -r --merged )时,您可以将其作为 Michael Krelin 使用

解答

  git push< remote> :其中remotebranchname> 

另见 git branch 用于 - 合并 - 未合并标志。


To delete a local branch in git I use git branch -d, but how do I safely remove a remote branch?

I would like to delete it only when the remote branch is merged to my current branch.

解决方案

The answer is partly covered here: How can I know in git if a branch has been already merged into master?

While that post copes with local branches, you could find remote branches that are merged or not using

  • git branch -r --merged to detect all remote branches that are already merged into the current
  • git branch -r --unmerged to do the opposite

  • git branch -r --no-merged is correct for the new version of Git and I'm not sure whether git branch -r --unmerged is applicable for old git.

Once you found that a specific remote branch is already merged (i.e. it appears when typing git branch -r --merged), you could delete it as Michael Krelin answers using

git push <remote> :<remotebranchname>

See also the documentation of git branch for the --merged and --unmerged flags.

这篇关于我如何安全地删除远程git分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆