Skip to content

Commit 7d17fc8

Browse files
authored
[tool] Update githooks/README with Git hooks uninstallation instructions (flutter#12311)
Added instructions for uninstalling Git hooks and managing specific hooks. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent dd11626 commit 7d17fc8

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

‎script/githooks/README.md‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ This directory contains Git hooks for the `flutter/packages` repository.
44

55
## Installation
66

7-
To install the Git hooks, run the following commands from the root of the repository:
7+
### Option 1: Install All Hooks (Recommended)
8+
9+
To install all Git hooks, run the following commands from the root of the repository:
810

911
```bash
1012
# Fetch dependencies for the githooks package
@@ -14,6 +16,50 @@ dart pub get -C script/githooks
1416
dart script/githooks/bin/install_hooks.dart
1517
```
1618

19+
### Option 2: Install Specific Hooks
20+
21+
To only use specific Git hooks in this directory long-term, create a script in your local `.git/hooks` directory that runs the desired hook.
22+
23+
For example, to install only the `pre-commit` hook, create `.git/hooks/pre-commit` with:
24+
25+
```bash
26+
#!/usr/bin/env bash
27+
exec dart script/githooks/bin/main.dart pre-commit "$@"
28+
```
29+
30+
Then, make it executable and ensure Git uses your local `.git/hooks` directory:
31+
32+
```bash
33+
chmod +x .git/hooks/pre-commit
34+
git config --unset core.hooksPath
35+
```
36+
37+
## Uninstallation
38+
39+
### Uninstall All Hooks
40+
41+
If you installed all hooks using Option 1, you can uninstall them by running:
42+
43+
```bash
44+
git config --unset core.hooksPath
45+
```
46+
47+
### Uninstall Specific Hooks
48+
49+
If you manually added a specific Git hook (Option 2), you can uninstall it by deleting the script from your `.git/hooks` directory:
50+
51+
```bash
52+
rm .git/hooks/pre-commit
53+
```
54+
55+
### Bypass Hooks Temporarily
56+
57+
To skip running hooks for a single action, pass the `--no-verify` flag. For example, to bypass the pre-commit hook during a commit:
58+
59+
```bash
60+
git commit --no-verify
61+
```
62+
1763
## Available Hooks
1864

1965
### pre-commit

0 commit comments

Comments
 (0)