提交 e5be63ff 编写于 作者: 片刻小哥哥's avatar 片刻小哥哥

添加 Git如何瘦身文档

上级 ad4d312a
#!/usr/bin/python
# coding: utf-8
import os
import subprocess
# 查询大文件
shell = """
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -5 | awk '{print$1}')"
"""
exitcode, output = subprocess.getstatusoutput(shell)
print("exitcode: ", exitcode)
print("output: ", type(output), output)
for i in output.split("\n"):
filename = i.split(" ")[1]
print(filename)
# 删除大文件记录
shell = """
git filter-branch -f --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch %s' --tag-name-filter cat -- --all
""" % filename
print(shell)
exitcode, output = subprocess.getstatusoutput(shell)
print(">>> ", exitcode)
# 提交代码
shell = "git push origin --force --all"
print(shell)
exitcode, output = subprocess.getstatusoutput(shell)
print(">>> ", exitcode)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册