{"id":50935131,"url":"https://github.com/piecioshka/git-similarity-index","last_synced_at":"2026-06-17T08:02:42.851Z","repository":{"id":263988145,"uuid":"890221844","full_name":"piecioshka/git-similarity-index","owner":"piecioshka","description":"🔨 Calculates the similarity index between two files.","archived":false,"fork":false,"pushed_at":"2026-01-12T15:49:38.000Z","size":110,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-23T12:34:49.455Z","etag":null,"topics":["cli","git"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piecioshka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"piecioshka","buy_me_a_coffee":"piecioshka","patreon":"piecioshka","custom":["https://www.paypal.me/piecioshka","https://patronite.pl/piecioshka"]}},"created_at":"2024-11-18T07:49:09.000Z","updated_at":"2026-01-08T13:34:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"e84e9206-7816-47c9-be18-c074b0bcd761","html_url":"https://github.com/piecioshka/git-similarity-index","commit_stats":null,"previous_names":["piecioshka/git-similarity-index"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/piecioshka/git-similarity-index","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piecioshka%2Fgit-similarity-index","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piecioshka%2Fgit-similarity-index/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piecioshka%2Fgit-similarity-index/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piecioshka%2Fgit-similarity-index/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piecioshka","download_url":"https://codeload.github.com/piecioshka/git-similarity-index/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piecioshka%2Fgit-similarity-index/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34439296,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","git"],"created_at":"2026-06-17T08:02:41.599Z","updated_at":"2026-06-17T08:02:42.845Z","avatar_url":"https://github.com/piecioshka.png","language":"TypeScript","funding_links":["https://github.com/sponsors/piecioshka","https://buymeacoffee.com/piecioshka","https://patreon.com/piecioshka","https://www.paypal.me/piecioshka","https://patronite.pl/piecioshka"],"categories":[],"sub_categories":[],"readme":"# git-similarity-index\n\n[![cli-available](https://badgen.net/static/cli/available/?icon=terminal)](#cli)\n[![node version](https://img.shields.io/node/v/git-similarity-index.svg)](https://www.npmjs.com/package/git-similarity-index)\n[![npm version](https://badge.fury.io/js/git-similarity-index.svg)](https://badge.fury.io/js/git-similarity-index)\n[![downloads count](https://img.shields.io/npm/dt/git-similarity-index.svg)](https://www.npmjs.com/package/git-similarity-index)\n[![size](https://packagephobia.com/badge?p=git-similarity-index)](https://packagephobia.com/result?p=git-similarity-index)\n[![license](https://img.shields.io/npm/l/git-similarity-index.svg)](https://piecioshka.mit-license.org)\n[![github-ci](https://github.com/piecioshka/git-similarity-index/actions/workflows/testing.yml/badge.svg)](https://github.com/piecioshka/git-similarity-index/actions/workflows/testing.yml)\n\n🔨 Calculates the similarity index between two files.\n\n## Motivation\n\nI would like to calculate the similarity between two files. Unfortunately, but Git does not provide a command that would count the ‘similarity index’. Therefore, I decided to write such a tool myself that counts this index.\n\n![](./screenshots/demo-similarity-index.png)\n\n## CLI\n\n```bash\nnpm install -g git-similarity-index\n\ngit-similarity-index mocks/file1.txt mocks/file2.txt\n# or\ngit-similarity-index mocks/file1.txt mocks/file2.txt --use-git\n```\n\n## Usage\n\n### `getSimilarityIndex` + `getLinesBytes`\n\n```js\nimport { getSimilarityIndex, getLinesBytes } from \"git-similarity-index\";\n\n(function () {\n  const toBytes = (text) =\u003e Buffer.from(text).toJSON().data;\n\n  const firstPattern = \"a\\n\";\n  const secondPattern = \"a\\nb\";\n  const similarityIndex = getSimilarityIndex(\n    getLinesBytes(toBytes(firstPattern)),\n    getLinesBytes(toBytes(secondPattern)),\n    toBytes(secondPattern).length,\n  );\n  console.log(similarityIndex); // 66.67\n})();\n```\n\n### `getSimilarityIndexForText`\n\n```js\nimport { getSimilarityIndexForText } from \"git-similarity-index\";\n\n(function () {\n  const firstPattern = \"a\\nb\\nc\\n\";\n  const secondPattern = \"a\\nb\\nc\\nd\";\n  const similarityIndex = getSimilarityIndexForText(\n    firstPattern,\n    secondPattern,\n  );\n  console.log(similarityIndex); // 85.71\n})();\n```\n\n### `getSimilarityIndexForFiles`\n\n```js\nimport { getSimilarityIndexForFiles } from \"git-similarity-index\";\n\n(async function () {\n  const similarityIndex = await getSimilarityIndexForFiles(\n    \"mocks/file1.txt\",\n    \"mocks/file2.txt\",\n  );\n  console.log(similarityIndex); // 46.34\n})();\n```\n\n### `getSimilarityIndexForFiles` (with `useGit` option)\n\n```js\nimport { getSimilarityIndexForFiles } from \"git-similarity-index\";\n\n(async function () {\n  const similarityIndex = await getSimilarityIndexForFiles(\n    \"mocks/file1.txt\",\n    \"mocks/file2.txt\",\n    { useGit: true },\n  );\n  console.log(similarityIndex); // 46.34\n})();\n```\n\n## Debug\n\nThe tool itself uses the `debug` library. You can enable debugging by setting the `DEBUG` environment variable.\n\n```bash\n# to display all logs\nDEBUG=git-similarity-index:* git-similarity-index mocks/file1.txt mocks/file2.txt\n\n# focus only of bytes\nDEBUG=git-similarity-index:bytes git-similarity-index mocks/file1.txt mocks/file2.txt\n\n# focus only of text\nDEBUG=git-similarity-index:text git-similarity-index mocks/file1.txt mocks/file2.txt\n\n# focus only of files\nDEBUG=git-similarity-index:files git-similarity-index mocks/file1.txt mocks/file2.txt\n```\n\n## License\n\n[The MIT License](https://piecioshka.mit-license.org) @ 2024\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiecioshka%2Fgit-similarity-index","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiecioshka%2Fgit-similarity-index","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiecioshka%2Fgit-similarity-index/lists"}