如你所知,django南迁移文件是通过下面的命令生成的;
# python manage.py schemamigration model_name --auto
有时,我忘记将迁移文件添加到项目存储库中。
在将其他项目文件提交到存储库之前,有没有办法在pycharm中显示手动生成的迁移文件的提醒以添加git repo?
请您参考如下方法:
根据 pancakes 的评论,我启用了 pre-commit 钩子(Hook)并在下面附加了几行:
ud=`git status -u | grep '^Untracked files:$'`
if [ -n "$ud" ];
then
cat <<\EOF
Warning: There are new files exists and not added to project repo.
EOF
exit 1
fi
现在,git 在新文件可用时发出警告,并在提交前中断进程。这也适用于带有错误 pop 窗口的 PyCharm。
