相关疑难解决方法(0)

git 提交前和提交后挂钩未运行

什么可能导致我的 git 提交前和提交后挂钩无法运行?

(请注意:这个问题不是重复的;其他每个问题的答案要么是chmod +x“没有文件扩展名”,要么这里的问题都不是)

它们是可执行的:

$ ls -alh .git/hooks/*-commit -rwxr-xr-x … .git/hooks/post-commit -rwxr-xr-x … .git/hooks/pre-commit

这是他们每个人的内容:

#!/bin/sh echo "$0 IS RUNNING" exit 1

手动运行它们:

$ .git/hooks/pre-commit .git/hooks/pre-commit IS RUNNING

但它们不会git在提交时运行:

$ git commit -am "Test hooks" [master d17c0f38] Test hooks 1 file changed, 1 insertion(+)

这是 git 2.16.2

git

14
推荐指数
3
解决办法
9633
查看次数

如何防止eslint阻止git commit?

我是eslint的新手,并且正在使用它来强制执行编码风格.但是,当我在我的代码中写一个'TODO'项时,我得到一个eslint警告,好吧没关系.但是,现在当我尝试git commit时,它会返回:

**** ESLint errors found :     
line 145, col 9, Warning - Unexpected 'todo' comment. (no-warning-comments)
Run Code Online (Sandbox Code Playgroud)

如何防止eslint阻止我提交?我希望它仍然警告我关于TODO等,但我希望能够提交我的代码.

git eslint

8
推荐指数
3
解决办法
6871
查看次数

有没有办法在执行`git merge`命令时绕过合并后的git钩子

我配置了合并后挂钩,以便(半手动)与另一个版本控制系统集成。但是有时我想避免钩子运行有什么方法可以绕过它git merge吗?

我知道有--no-verify命令行参数git commit。这种解决方案非常适合我的用例,但似乎 --no-verify不适用于git commit命令。

git merge hook githooks

6
推荐指数
4
解决办法
4324
查看次数

禁用单个 git 命令的钩子

鉴于我需要在我的钩子脚本中使用 git,我希望我的钩子脚本不要自己触发钩子。所以我想在每个命令的基础上跳过钩子。

即我正在寻找一个选项,如:

git --no-hooks some-git-command

git hook command-line-interface

6
推荐指数
1
解决办法
517
查看次数

理解git commit --only和pre-commit hooks

我正在使用预提交钩子来重新格式化代码,一般来说,它可以工作; 它重新格式化和git add任何暂存的文件,结果提交包含所需的重新格式化的代码.

但是,它不能很好地使用git commit --only(这是JetBrains IDE使用的变体),我试图理解为什么.git commit --only预提交钩子的组合和预提交钩子导致不合需要的索引/工作树状态,如以下事件序列中所述:

如果我对文件进行了一次格式化错误的小改动然后运行git status,这就是我所看到的:

On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   file.php

no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)

如果我然后提交使用git commit --only -- file.php,则预提交挂钩运行,并且提交已更改并重新格式化file.php.

但是,如果我再次运行git status …

git jetbrains-ide githooks

4
推荐指数
1
解决办法
721
查看次数

Git 预提交钩子配置

我正在按照办公室指南创建钩子并将其添加到预提交检查过程中。我需要创建 3 个文件

  .pre-commit-config.yaml

  .pre-commit-hooks.yaml

   theCheckFile.sh
Run Code Online (Sandbox Code Playgroud)

配置文件配置hooks文件该文件调用theCheckFils.sh文件来检查我的代码风格。

Q.1我应该把这些文件放在哪里?我目前将它们放入我的项目文件夹中,并编辑 .gitignore 文件以忽略所有它们,有更好的建议吗?或者这样就可以了。

Q.2 pre-commit-config.yaml 文件中需要 rev,我应该在哪里找到此信息,我当前使用的代码 Repo 中没有版本信息,我可以随机创建一个数字吗?

git pre-commit-hook pre-commit.com

3
推荐指数
1
解决办法
1万
查看次数