小编Gin*_*sus的帖子

我可以从每个预提交挂钩中排除文件(除了一个)而不重复自己吗?

我想制作一个符合 \xe2\x80\x99s REUSE标准的 Git 存储库。我想使用重用预提交挂钩来帮助确保 I\xe2\x80\x99m 兼容。重用规范要求我创建一个名为 \xe2\x80\x9cLICENSES\xe2\x80\x9d 的文件夹,其中包含我的项目使用的每个许可证。我\xe2\x80\x99m 使用其他几个挂钩,并且我不希望这些挂钩检查或修改文件夹中的任何内容LICENSES/。我希望除重用之外的每个钩子都排除在外LICENSES/。(旁注:目前,重用挂钩似乎不受 排除 的影响LICENSES/,但这可能应该得到修复)。这里\xe2\x80\x99是我迄今为止尝试过的:

\n
exclude: \'^LICENSES/\'\nrepos:\n    -\n        repo: https://github.com/pre-commit/pre-commit-hooks\n        rev: v4.0.1\n        hooks:\n            - id: check-case-conflict\n            - id: end-of-file-fixer\n            - id: mixed-line-ending\n            - id: trailing-whitespace\n    # I\xe2\x80\x99m using identity instead of reuse here for testing and to better\n    # illustrate the problem.\n    -\n        repo: meta\n        hooks:\n            -\n                id: identity\n                exclude: "^$"\n
Run Code Online (Sandbox Code Playgroud)\n

那\xe2\x80\x99 不起作用。看起来除了全局模式之外,每个钩子排除模式也适用。我希望应用每个钩子排除模式而不是全局模式。

\n

我可以在每个钩子上使用每个钩子排除模式,除了一个:

\n
repos:\n    -\n        repo: https://github.com/pre-commit/pre-commit-hooks\n …
Run Code Online (Sandbox Code Playgroud)

git pre-commit.com

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

如何删除包含子模块的 Git 工作树?

让\xe2\x80\x99s 说我有一个包含子模块的Git 存储库:

\n
$ mkdir main-worktree\n$ cd main-worktree\n$ git init\nInitialized empty Git repository in /\xe2\x80\xa6/main-worktree/.git/\n$ git submodule add https://github.com/octocat/Hello-World.git Hello-World\nCloning into \'/\xe2\x80\xa6/main-worktree/Hello-World\'...\nremote: Enumerating objects: 13, done.\nremote: Total 13 (delta 0), reused 0 (delta 0), pack-reused 13\nReceiving objects: 100% (13/13), done.\n$ git commit -m \'Create submodule\'\n[main (root-commit) 66070b6] Create submodule\n 2 files changed, 4 insertions(+)\n create mode 100644 .gitmodules\n create mode 160000 Hello-World\n
Run Code Online (Sandbox Code Playgroud)\n

然后为该存储库创建另一个工作树(包含子模块的工作树):

\n
$ git worktree add ../secondary-worktree\nPreparing worktree (new branch \'secondary-worktree\')\nHEAD …
Run Code Online (Sandbox Code Playgroud)

git git-submodules git-worktree

9
推荐指数
1
解决办法
2022
查看次数