从Git Remotes清除分支
git-sweep3k的Python项目详细描述
一个命令行工具,帮助您清理已合并的git分支 变成主人。
这是一个fork,它添加了python 3支持(除了python 2之外)。这个 原件在https://github.com/arc90/git-sweep。
问题
您的master分支通常是所有代码所在的位置。所有特征 分支应该是短命的,一旦它们被合并到master中 完成
随着时间的推移,您可以建立一个长的分支列表,这些分支不是 需要更长时间。它们已经合并到master,我们如何处理它们 现在?
答案
使用git-sweep可以安全地删除 合并到master中。
要安装它,请运行:
$ pip install git-sweep3k
自己试试(安全)
要查看git sweep检测到的分支合并到主节点中的列表 分行:
--dry-run选项不会对存储库进行任何更改:
$ git sweep --dry-run Fetching from the remote These branches have been merged into master: branch1 branch2 branch3 branch4 branch5 To delete them, run again without --dry-run
如果您对列表满意,可以运行删除这些 远程分支:
$ git sweep Fetching from the remote These branches have been merged into master: branch1 branch2 branch3 branch4 branch5 Delete these branches? (y/n) y deleting branch1 (done) deleting branch2 (done) deleting branch3 (done) deleting branch4 (done) deleting branch5 (done) All done! Tell everyone to run `git fetch --prune` to sync with this remote. (you don't have to, yours is synced)
注意:这可能需要一点时间,它正在通过管道与遥控器通话。
您还可以为远程分支和主分支赋予不同的名称:
$ git sweep --dry-run --master=develop --origin=github ...
告诉它跳过默认情况下的git fetch:
$ git sweep --dry-run --no-fetch These branches have been merged into master: branch1 To delete them, run again without --dry-run
跳过某些分支:
$ git sweep --dry-run --skip=develop Fetching from the remote These branches have been merged into master: important-upgrade upgrade-libs To delete them, run again without --dry-run
一旦git sweep找到分支,就会要求您确认 删除它们:
Delete these branches? (y/n)
您可以使用--force选项绕过此选项并开始删除 立即:
$ git sweep --skip=develop --force Fetching from the remote These branches have been merged into master: important-upgrade upgrade-libs deleting important-upgrade (done) deleting upgrade-libs (done) All done! Tell everyone to run `git fetch --prune` to sync with this remote. (you don't have to, yours is synced)
要求
- 吉特=1.7
- python>;=2.6或>;=3.2
许可证
友好邻里麻省理工执照。