- Settings -> Plugins -> Pre Commit Hook Plugin - install
- Create a file named pre-commit-hook.sh or pre-commit-hook.bat for Windows, in your project root, exit with non-zero code to 'fail' the commit.
- chmod a+x pre-commit-hook.sh
- Settings -> Tools -> Pre Commit Hook
- Put a path to your script
pre-commit-hook.sh
cd ~/PycharmProjects/your-project-folder
docker exec container-name flake8 `git diff HEAD --name-only|grep ".py" || echo "path-to-folder-where-git-init"` || exit 1