git2string
git2string is a powerful tool that simplifies the process of converting an entire Git repository into a single LLM-friendly text file, which is easy to upload. It also tells you how many tokens the text file will consume. So, it will hopefully be saving you a lot of time and effort.
It will automatically ignore all binary files. Additionally, it will respect your .gitignore. You can also create a .r2pignore file in your repo to specify the files that should be skipped for prompt generation.
Installation
pip3 install git2string
Usage
git2string <url of repository>
For example:
git2string https://github.com/mozilla/experimenter
The output would look like this:
ℹ Cloning repository to ./tmpohen963u
✔ Using tokenizer for model gpt2
Concatenating: 100%|██████████████████████| 3331/3331 [00:00<00:00, 7547.49it/s]
✔ All valid files have been concatenated into llm_prompt.txt
ℹ 21334492 tokens are present in the prompt
If you have cloned your desired repository already, you can just specify its path.
git2string <repo root directory>
By default, the prompt will be generated in a file called llm_prompt.txt. You can specify a different filename as follows:
git2string <repo root directory> --output-file <filename>
This tool uses OpenAI's tiktoken to count the number of tokens in the generated prompt. By default, gpt2's tokenizer will be used. But you can count tokens for most OpenAI models.
git2string <repo root directory> --openai-model <model name>
For example:
git2string /tmp/myrepo --openai-model gpt-4o
Release files for git2string 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| git2string-0.1.5.tar.gz | 12.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| git2string-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.7 kB
Release files / git2string-0.1.5.tar.gz
| Download URL | git2string-0.1.5.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f5f83aad0122100408b0b19ada4350369bd665f9a23c901ca013196d57d2a9d
|
|
BLAKE2b-256 checksum How to use checksums |
6e4e035c58eed29e0f10dad90342f0bf236b76e8fc148623c287df9e382dbd82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / git2string-0.1.5-py3-none-any.whl
| Download URL | git2string-0.1.5-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82713a7adf14e3744fe6d6766b0f93dce9911e52d06adf0cfb93abafa323c3cd
|
|
BLAKE2b-256 checksum How to use checksums |
6ce40f102f6e12620db8032b3c98c7df1144d46b308acdec41cdef52ad9a0500
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|