Skip to main content

git-semantic-similarity

Search git commit messages by semantic similarity with embeddings from sentence-transformers.

Embeddings are generated locally, can be stored on disk for faster reuse, and can be checked into git for sharing embeddings with other users.

$ gitsem "project scaffolding"

Commit 403836d2ee4900579b0d1e8169dd4bfebddab0ba
Author: Foo Bar <foo@bar.com>
Date:   2024-09-23 19:08:05
Similarity: 0.2299

    Change model, add src folder

Commit d2909a8ec352a881ab05cab8b8a67038b063f37a
Author: Foo Bar <foo@bar.com>
Date:   2024-09-23 19:08:05
Similarity: 0.2086

    Initial commit

...

Commit a09923166072aca4910e92272ef161e3398b1d89
Author: Foo Bar <foo@bar.com>
Date:   2024-09-23 19:08:05
Similarity: -0.0716

    Remove buggy rounding

Installation

First, install pipx. Then, install with pipx:

pipx install git-semantic-similarity

Usage

In a git repository, run: gitsem "query string"

To only show the 10 most relevant commits:

gitsem "changes to project documentation" -n 10

To use another pretrained model, for example a smaller and faster model:

gitsem "user service refactoring" --model sentence-transformers/all-MiniLM-L6-v2

A list of supported models can be found here

The tool supports forwarding arguments to git rev-list For example, to only search in the 10 most recent commits:

gitsem "query string" -- -n 10

Or to filter by a specific author:

gitsem "query string" -- --author bob

Or you can format the output in a single line for further shell processing:

gitsem "query string" --sort False --oneline -- n 100 | sort -n -r | head -n 10

Arguments

  • -m, --model [STRING]:
    A sentence-transformers model to use for embeddings. Default is all-mpnet-base-v2.

  • --model-args [STRING]:
    Additional arguments for SentenceTransformers model initialization in format: key1=value1,key2=value2. For example: truncate_dim=256,trust_remote_code=true

  • -c, --cache [BOOLEAN]:
    Whether to cache commit embeddings on disk for faster retrieval. Default is True.

  • --cache-dir [PATH]:
    Directory to store cached embeddings. If not specified, defaults to git_root/.gitsem/model_name.

  • --oneline:
    Use a concise output format.

  • --sort [BOOLEAN]:
    Sort results by similarity score. Default is True.

  • -n, --max-count [INTEGER]:
    Limit the number of results displayed. If not provided, no limit is applied.

  • -b, --batch-size [INTEGER]:
    Batch size for embedding commits. Default is 100.

  • query [STRING]:
    The query string to compare against commit messages.

  • git_args [STRING...]:
    Arguments after -- will be forwarded to git rev-list.

License

MIT

Release files for git-semantic-similarity 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-semantic-similarity 1.0.7
File Size Uploaded
git_semantic_similarity-1.0.7.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-semantic-similarity 1.0.7
File Interpreter ABI Platform
git_semantic_similarity-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 15.0 kB

Release files / git_semantic_similarity-1.0.7.tar.gz

Download URL git_semantic_similarity-1.0.7.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
65a2edce83ff824595eba082918164d8f0a4fe02e9056ff92c2e8be6769c4836
BLAKE2b-256 checksum
How to use checksums
c0db3f2bf211524732d425a1e427c15dfcf23b2e9971fafd266686f897b9fba3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 2, 2025.

Transparency log

Release files / git_semantic_similarity-1.0.7-py3-none-any.whl

Download URL git_semantic_similarity-1.0.7-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fae33e92c9f0752e6090cd213f7f2d72e8b5e6e6b89c126cc65fbae5346f2b7d
BLAKE2b-256 checksum
How to use checksums
bc6054fdf60ca4180a680b4ca0ccea5f228769c04db11ce483a5591423c92898
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 2, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page