Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 在使用Git提交之前检查代码中的消息注释_Linux_Macos_Git_Git Commit_Pre Commit - Fatal编程技术网

Linux 在使用Git提交之前检查代码中的消息注释

Linux 在使用Git提交之前检查代码中的消息注释,linux,macos,git,git-commit,pre-commit,Linux,Macos,Git,Git Commit,Pre Commit,如果经常发现自己在本地开发时在代码中写下有用的消息。请将此代码段作为简单示例: # Public API namespace :api do namespace :v1 do # REMOVE THE FIRST LINE WHEN DONE TESTING get :delivery_report, to: 'delivery_report#index' post :delivery_report, to: 'delivery_report#index' end

如果经常发现自己在本地开发时在代码中写下有用的消息。请将此代码段作为简单示例:

# Public API
namespace :api do
  namespace :v1 do
    # REMOVE THE FIRST LINE WHEN DONE TESTING
    get :delivery_report, to: 'delivery_report#index'
    post :delivery_report, to: 'delivery_report#index'
  end
end
这里的要点是,当我完成了,我觉得我终于可以完成我的工作了,我需要记住,我必须删除get:delivery_report这一行,改为:'delivery_reportindex'


是否可以告诉git,在接受提交之前或者在转移之前,它应该警告我代码中有一行内容?在本例中,这将是我的注释或任何其他预定义行。

Git支持一个预提交钩子,在该钩子中,您可以测试用户建议提交的内容,并在某些条件适用时强制提交失败

看到和