清理Git远程的分支
项目描述
这是一个命令行工具,帮助您清理已合并到master分支的Git分支。
这是一个添加Python 3支持(除了Python 2)的分支。原始版本在https://github.com/arc90/git-sweep。
问题
您的master分支通常是所有代码存放的地方。所有功能分支都应该是短命的,一旦完成就合并到master。
随着时间的推移,您可能会积累一个非常长的不再需要的分支列表。它们已经被合并到master,我们该怎么办?
答案
使用git-sweep,您可以安全地删除已合并到master的远程分支。
要安装它,运行
$ pip install git-sweep3k
亲自尝试(安全地)
查看git-sweep检测到的已合并到您的master分支的分支列表
--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)
注意:这可能需要一些时间,它正在通过管道与远程进行通信。
您还可以为您的远程分支和master分支指定不同的名称
$ 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)
要求
Git >= 1.7
Python >= 2.6 或 >= 3.2
许可证
友好的MIT许可。
关闭
git-sweep3k-0.3.1.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | e3244b72d5140f77842f1125376a85053737b75cd2502a32860d5a65638f99a8 |
|
MD5 | eab94a182d41461219ac403c4dfc1448 |
|
BLAKE2b-256 | 121bef0f82ac34778c39b388771df670d548f56e54f0113f2faca4404eb13f54 |