How do I safely delete a remote git branch?

邮差的信 提交于 2019-12-03 23:20:54
eckes

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.

Just to point out that for unmerged branches it seems the option now is --no-merged as explained on http://git-scm.com/docs/git-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!