{"id":17988333,"url":"https://github.com/fcharlie/git-analyze-demo","last_synced_at":"2026-04-27T22:32:09.754Z","repository":{"id":47502691,"uuid":"77444191","full_name":"fcharlie/git-analyze-demo","owner":"fcharlie","description":"crazy git tools git-analyze demo","archived":false,"fork":false,"pushed_at":"2021-08-28T14:03:04.000Z","size":9891,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T03:27:43.427Z","etag":null,"topics":["git"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fcharlie.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-27T09:40:10.000Z","updated_at":"2021-02-18T06:12:13.000Z","dependencies_parsed_at":"2022-09-23T11:30:35.984Z","dependency_job_id":null,"html_url":"https://github.com/fcharlie/git-analyze-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fcharlie/git-analyze-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcharlie%2Fgit-analyze-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcharlie%2Fgit-analyze-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcharlie%2Fgit-analyze-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcharlie%2Fgit-analyze-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fcharlie","download_url":"https://codeload.github.com/fcharlie/git-analyze-demo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fcharlie%2Fgit-analyze-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32358509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git"],"created_at":"2024-10-29T19:11:27.372Z","updated_at":"2026-04-27T22:32:09.740Z","avatar_url":"https://github.com/fcharlie.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Git Analyze tool\n\n在用户使用 git 作为版本控制工具时,可能会将一些体积较大的文件提交到历史记录之中,由于 git 是一个分布式的版本控制系统,\n并且基于快照的存储特性,这个时候,用户的存储库提交将变得非常大. git-analyze 是一个可以帮助用户检索出从哪一次提交\n引入了原始体积超过限制的文件. git-rollback 则可以根据分支上的 commit 和从当前回退的版本数实现回滚,并且保留当前\n工作目录的文件不改变,用户可以重新创建提交.\n\n## 构建\n\nWindows 依赖：\n+   Visual Studio 2017 15.7 or Later\n+   CMake 3.12 or Later\n\nUnix 依赖：\n+   GCC 7.3 or Later (Best GCC 8)\n+   CMake 3.12 or Later\n\n```\ngit clone https://gitee.com/oscstudio/git-analyze.git\n```\n\nWindows 构建：\n\n```sh\nmkdir build\ncd build\ncmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release ..\ncpack\n```\n然后打开安装包即可。这里需要注意，Ninja 并不能很好的支持 `cmake ExternalProject` 特性，因此会构建失败。\n\nUnix 构建：\n\n```sh\nmkdir build\ncd build\ncmake -DCMAKE_BUILD_TYPE=Release .. -DCMAKE_INSTALL_PREFIX=/opt/oscstudio\nmake\nmake install\n```\n## Analyze 工具\n\ngit-analyze 命令行参数\n```sh\nOVERVIEW: GIT analyze tools\nUsage: git-analyze \u003coptions\u003e...] [--] [\u003cpathspec\u003e...] [\u003crefs|branches\u003e ...]\nOPTIONS:\n  -h [--help]      print usage and exit\n  --limitsize      set analyze engine limit blob size\n  --warnsize       set analyze engine warn blob size\n  --timeout        set analyze engine lifycycle\n  --who            show who is commit author\n  --all            analyze will scanf all refs\n```\n\n默认情况下, git-analyze 扫描当前目录的仓库的 HEAD 指向的分支,如果要扫描其他目录或者其他分支需要额外的设置参数,\n仓库目录可以是工作目录的根目录和裸仓库的目录, 分支名可以使用引用或者本地分支名,二者相对顺序必须与下相同.\n\n\u003egit-analyze /path/to/repo master\n\n其中 limitsize warnsize 参数都是整数,单位是 MB 默认值为 100 MB 和 50 MB, timeout 单位是秒,可以不设置, 这几个都可以使用 --limitsize=100 或者 --limitsize 100 这样的格式.\n\nwho 这个参数是一个开关,单命令行参数中存在 --who 时, 扫描到大文件时将显示提交 作者 和 提交信息.\n\nall 这个开关如果开启时,将扫描所有的引用.\n\n这些参数没有顺序要求.\n\n例图:\n\n![Analyze Example](./docs/images/analyze-001.png)\n\n## Rollback 工具\n\ngit-rollback 命令行参数\n\n```sh\nOVERVIEW: GIT rollback tools\nUsage: git-rollback \u003coptions\u003e...] [--] [\u003cpathspec\u003e...] [\u003crefs|branches\u003e ...]\nOPTIONS:\n  -h [--help]      print usage and exit\n  --git-dir        set rollback repository path\n  --backid         set rollback commit id\n  --backrev        set rollback current back X rev\n  --refname        set rollback current reference name\n\n```\n参数格式与 git-analyze 类似, --force 将强制运行 git gc 并清除悬空对象. 当 未指定 git-dir 时,为当前目录,未指定 refname 时,为 HEAD 指向的分支.\n\n## Cheat 工具\n\ngit-cheat 可以基于当前分支创建一个只有一个 commit 的分支，此分支的提交信息，树对象等都与当前分支\n一致，但没有父提交。很容易看到的一个场景是，用户清理项目后，创建一个提交，然后在此提交的基础上\n使用 git-cheat 开源。\n\n命令格式：\n\n```shell\ngit-cheat branch commit-message\n```\n\n## Pre-Commit 工具\n\npre-commit 是 git 的一类钩子，当用户创建提交，也就是 git commit -m 后，如果存储库中有此类钩子，\ngit-commit 就会执行 pre-commit 钩子，用户在创建提交时，很容易将大文件或者二进制文件提交到存储库，\n等到推送到代码托管平台被拒绝时撤销更改就非常麻烦了。使用 pre-commit 可以避免此类问题，\n用户将 pre-commit 软链到 `.git/hooks/pre-commit` 就行了，如果要修改配置，可以使用 git config 修改，\ngit config 添加 --global 参数时修改全局设置。\n\n这里 limitsize 即限制文件大小，单位可以是 K M G 不区分大小写。warnsize 是警告提示大文件，大小为 limitszie 的一半就可以了。\n\n而 filters 是一个正则表达式，过滤后缀名的，一般网络上可以找到。filterbroken 是设置当存在过滤文件时是否终止提交。默认为 false。\n\n```shell\ngit config commit.limitsize 100M # limit file size\ngit config commit.warnsize 50M # report warning file size\ngit config commit.filters \"\\.(exe|obj|pdb)$\" # filter regex\ngit config commit.filterbroken true # filter broken when find\n```\n\n## Git Complete 工具\n\n此工具创建 整整一年的提交\n\n```shell\ngit-complete dir branch 'commit message' 2018～2100\n```\n\n## Update 钩子\n\nUpdate 钩子是一个实验性的钩子用户实现 git 只读目录功能，相关的原理可以查看 [实现 Git 目录权限控制](https://forcemz.net/git/2019/04/01/ImplementGitDirPermissionControl/)\n\n## 与 GIT 整合\n\ngit 支持使用 git subcommand 的格式运行特定命令,比如 git add 对应的命令就是 git-add , 当用户需要直接运行 git analyze 这种方式运行这些命令,\n有几种方法可以做到,第一种是将 git-analyze 加入环境变量,然后可以直接运行\n\n```bash\n git analyze . refs/heads/master\n git rollback --backrev 1\n ```\n\n同样也可以使用软链接的方式将命令链接到系统目录, 在 POSIX 系统中,或者 Windows Subsystem for Linux 可以使用 ln -s , 在 Windows 中\n可以使用 mklink  /d .\n\n## Copyright\n\nAuthor: Force Charlie  \nCopyright \u0026copy; 2019, GITEE.COM, All Rights Reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcharlie%2Fgit-analyze-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffcharlie%2Fgit-analyze-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffcharlie%2Fgit-analyze-demo/lists"}