安装git-format-staged后,Sourcetree中提交代码报错的解决方案
pre-commit文件中内容为:
git-format-staged --formatter "swiftformat stdin --stdinpath '{}'" "*.swift"
在终端中,git commit不会报错。Sourcetree中提交具体错误:

git-format-staged或者swiftformat命令找不到。
解决方案一:
利用Automator(自动操作)新建一个SourceTree应用程序。



export PATH=/usr/local/bin:/opt/homebrew/bin/:$PATH open -a Sourcetree

保存之后即可。

拖动icon,修改新建的app icon
方案二:
将pre-commit中命令修改为:
/usr/local/bin/git-format-staged --formatter "/opt/homebrew/bin/swiftformat stdin --stdinpath '{}'" "*.swift"
浙公网安备 33010602011771号