Skip to content

Commit 82de5b1

Browse files
authored
Update README.md
1 parent 61cf437 commit 82de5b1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ repos:
5858
```
5959

6060
> [!IMPORTANT]
61-
> If your `pre-commit` runs longer than expected, it is highly recommended to add `files` in `.pre-commit-config.yaml` to limit the scope of the hook. This helps improve performance by reducing the number of files being checked and avoids unnecessary processing. For example below:
61+
> If your `pre-commit` runs longer than expected, it is highly recommended to add `files` in `.pre-commit-config.yaml` to limit the scope of the hook. This helps improve performance by reducing the number of files being checked and avoids unnecessary processing. Here's an example configuration:
6262

6363

6464
```yaml
@@ -73,6 +73,14 @@ repos:
7373
files: ^(src|include)/.*\.(cpp|cc|cxx|h|hpp)$
7474
```
7575

76+
Alternatively, if you want to run the hooks manually on only the changed files, you can use the following command:
77+
78+
```bash
79+
pre-commit run --files $(git diff --name-only)
80+
```
81+
82+
This approach ensures that only modified files are checked, further speeding up the linting process during development.
83+
7684
## Output
7785

7886
### clang-format Example

0 commit comments

Comments
 (0)