Git Recursive Grep
git-rg is a command-line tool for recursively searching for files in Git repositories that contain specific text patterns using regular expressions. It's useful for finding sensitive information like accidentally committed passwords or API keys within .git directories.
Installation
pip install git-rg
python3 -m pip install git-rg
pipx install git-rg
To install latest version from Github:
pipx install git+https://github.com/s3rgeym/git-rg
Usage
git-rg <pattern> [path] [-B <num>] [-A <num>] [-L <maxline>]
Example
To search for passwords in all .git files within the current directory and show 2 lines before and after the match:
git-rg "(?i)password\s*=\s*['\"]?(\w+)['\"]?" ~/projects -B 2 -A 2
Output seems like this:
Metadata
Release files for git-rg 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| git_rg-0.2.1.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| git_rg-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.7 kB
Release files / git_rg-0.2.1.tar.gz
| Download URL | git_rg-0.2.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5323e127396cac91673c4d8ace41303520f1bb5f8a5a653df82db28bf9bab6a8
|
|
BLAKE2b-256 checksum How to use checksums |
0425bdda7256bc3ce0f75e181d72d800c706c604299b105fb71257ca3d1c9802
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
|
Release files / git_rg-0.2.1-py3-none-any.whl
| Download URL | git_rg-0.2.1-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
db06ae0ea694bc331bf487fa9b07a17bdbcce8cac086fbd3c080d4dc4754a899
|
|
BLAKE2b-256 checksum How to use checksums |
19918f58667c3efce1b351de3c42916a55b30a47fd151f683f5d0d647e232a71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.6
|