我如何安全地删除远程git分支? [英] How do I safely delete a remote git branch?
问题描述
要在git中删除本地分支,我使用 git branch -d
,但是如何安全地删除远程分支?
只有当远程分支合并到当前分支时,我才想将其删除。
答案部分在这里覆盖: 尽管该文章适用于本地分支机构,但您可以找到合并或不使用的远程分支机构 一旦你f发现特定的远程分支已经合并(即,它出现在输入
$ b已经合并成master了$ b
git branch -r --merged
来检测已经合并到当前的所有远程分支
git分支-r --unmerged
做相反的处理
git branch -r --no-merged
对于新版本的 Git
是正确的,我不确定是否 git branch -r --unmerged
适用于旧的 git
。
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 currentgit branch -r --unmerged
to do the oppositegit branch -r --no-merged
is correct for the new version ofGit
and I'm not sure whethergit branch -r --unmerged
is applicable for oldgit
.
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屋!