A command-line tool that uses OpenAI's embeddings and GPT models to help you find relevant commits in your git repository based on natural language queries.
- Semantic search through git commit history using OpenAI embeddings
- Automatic detection of git repository
- Configurable number of relevant commits to analyze
- Natural language querying of commit history
- Clone the repository:
git clone https://github.com/trulsmoholt/gitsearch.git
cd gitsearch
- Install the required packages:
pip install -r requirements.txt
- Install the package locally:
pip install --user .
Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY="your-api-key-here"
Or add it to your ~/.zshrc
or ~/.bashrc
:
echo 'export OPENAI_API_KEY="your-api-key-here"' >> ~/.zshrc
source ~/.zshrc
From within a git repository:
gitsearch "fix login button not working"
--repo
: Path to git repository (defaults to current directory)--api-key
: OpenAI API key (defaults to OPENAI_API_KEY environment variable)--model
: OpenAI model to use (default: "gpt-4")--days
: Number of days to look back (default: 30)--top-k
: Number of most relevant commits to analyze (default: 5)
Examples:
# Search in specific repository
gitsearch "fix login button" --repo /path/to/repo
# Look back 60 days
gitsearch "fix login button" --days 60
# Analyze top 3 most relevant commits
gitsearch "fix login button" --top-k 3
# Use specific API key
gitsearch "fix login button" --api-key your-api-key-here
For development and testing, you can run the script directly:
python gitsearch.py "your query"
- Python 3.7+
- OpenAI API key
- Git repository
- openai
- gitpython
- numpy