【问题标题】:git cleanup old branchesgit清理旧分支
【发布时间】:2012-06-24 12:35:37
【问题描述】:

我想创建一个 git 命令,该命令将删除当前分支中包含所有提交的所有分支,例如

$ git branch
  groups
* master

$ git cleanup-branches
deleted groups # all commits are included in master

$ git branch
* master

我将如何创建它?

【问题讨论】:

标签: git git-bash


【解决方案1】:

您可以在此处使用git branch -d,因为它不会删除尚未合并到您当前分支的任何分支:

git config --global alias.cleanup-branches \
'!git branch | grep -v "\*" | awk "{ print $1 }" | xargs git branch -d'

刚刚在本地尝试过,它成功了,虽然看着它工作有点可怕。

【讨论】:

  • 哈!是的,这是一种方法,尝试删除所有内容!话虽如此,这似乎确实是一种可靠的方法。
猜你喜欢
  • 2011-03-12
  • 2018-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-02
  • 2022-11-25
  • 1970-01-01
相关资源
最近更新 更多