配置一下 PATH,保证最终 which git 指向的地址是 /opt/homebrew/bin/git
网上看了半天,没有找到可以用的方法,自己尝试修改 .git/hooks/pre-push 文件
修改前, command 这一行就是检测有没有安装 git-lfs
1 2 3
#!/bin/sh command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; } git lfs pre-push "$@"
+ 修改后,手动加上 `git-lfs` 所在的路径
1 2 3 4
#!/bin/sh export PATH=$PATH:/opt/homebrew/bin/ command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nThis repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting the 'pre-push' file in the hooks directory (set by 'core.hookspath'; usually '.git/hooks').\n"; exit 2; } git lfs pre-push "$@"