调试git-hooks的最佳方法 [英] Best way to debug git-hooks

查看:160
本文介绍了调试git-hooks的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

调试git-hooks的最佳方法是什么?

What is the best way to debug git-hooks?

我更喜欢的方式是添加语句以将输出添加到日志文件.例如,以下.

The way I prefer is adding statements to add output to a log file. For example, the following.

echo 'post-receive executed' >> hooks.log

是否有更好的记录方法?

Is there a better approach or way to do logging?

推荐答案

这是一个古老的问题,但是对于未来的读者来说,一个建议是:

This is an old question, but for future readers, one recommendation would be :

我怀疑是脚本本身需要检查,但是事实证明如此,那么下一步就是做通常要调试的shell脚本(因为这是默认设置) commit-msg钩子是).

I doubt that it is the script itself which needs to be looked at, however if that turns out to be the case, then the next step is to do what you normally would to debug shell scripts (since that is what the default commit-msg hook is).

我首先将she-bang线从#!/bin/sh更改为#!/bin/sh -xv,然后在执行git commit --amend

I would start by changing the she-bang line from #!/bin/sh to #!/bin/sh -xv and then revel in the uber-verbose output as the script is executed when you do a git commit --amend

这篇关于调试git-hooks的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆