利用Git Hook实现服务器端文件提交大小限制

利用git hooks,在服务器端每次接收到push的时候进行文件信息检查,若超过限制则拒绝提交。 具体实现:在update hook中对提交的文件进行检查,利用git log命令查询所有新提交的分支,利用git cat-file 命令递归查询文件树、查询文件大小,若超限则返回1拒绝提交。 #!/bin/bash # # An example hook script to block unannotated tags from entering. # Called by "git receive-pack" with arguments: refname sha1-old sha1-new # # To enable this hook, rename this file to "update". # # Config # ------ # hooks.allowunannotated # This boolean sets whether unannotated tags will be allowed into the # repository. By default they won't be. # hooks.allowdeletetag # This boolean sets whether deleting tags will be allowed in the # repository....

May 7, 2022 · 3 min · Andyliu

Git Notes

Delete branchs local: git branch -d <localBranchName> remote: git push origin --delete <remoteBranchName>

December 22, 2021 · 1 min · Andyliu

Git large file versioning

Download git-lfs on https://git-lfs.github.com/, and run the installation package for windows. Once downloaded and installed, set up Git LFS for your user account by running:git lfs install. You only need to run this once per user account. In each Git repository where you want to use Git LFS, select the file types you’d like Git LFS to manage (or directly edit your .gitattributes). You can configure additional file extensions at anytime....

November 22, 2021 · 1 min · Andyliu