{"id":22730250,"url":"https://github.com/ert78gb/git-utils","last_synced_at":"2026-04-18T06:37:09.349Z","repository":{"id":37182856,"uuid":"240769204","full_name":"ert78gb/git-utils","owner":"ert78gb","description":"A few useful command to get git infos","archived":false,"fork":false,"pushed_at":"2023-03-29T01:57:55.000Z","size":842,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-23T02:00:01.526Z","etag":null,"topics":["git","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/ert78gb.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-15T18:43:03.000Z","updated_at":"2021-11-06T10:27:19.000Z","dependencies_parsed_at":"2023-02-09T14:01:42.067Z","dependency_job_id":null,"html_url":"https://github.com/ert78gb/git-utils","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ert78gb/git-utils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgit-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgit-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgit-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgit-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ert78gb","download_url":"https://codeload.github.com/ert78gb/git-utils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ert78gb%2Fgit-utils/sbom","scorecard":{"id":381885,"data":{"date":"2025-08-11","repo":{"name":"github.com/ert78gb/git-utils","commit":"c4cba8415afc7316755305b61c8fcb135459fa81"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/9 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:28: update your workflow using https://app.stepsecurity.io/secureworkflow/ert78gb/git-utils/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/ert78gb/git-utils/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql-analysis.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/ert78gb/git-utils/codeql-analysis.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/ert78gb/git-utils/nodejs.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/nodejs.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/ert78gb/git-utils/nodejs.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/nodejs.yml:29","Info:   0 out of   5 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/codeql-analysis.yml:1","Warn: no topLevel permission defined: .github/workflows/nodejs.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":7,"reason":"SAST tool detected but not run on all commits","details":["Info: SAST configuration detected: CodeQL","Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T15:38:22.665Z","repository_id":37182856,"created_at":"2025-08-18T15:38:22.665Z","updated_at":"2025-08-18T15:38:22.665Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31959882,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"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":["git","nodejs"],"created_at":"2024-12-10T18:13:56.300Z","updated_at":"2026-04-18T06:37:09.327Z","avatar_url":"https://github.com/ert78gb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-utils\n\nA few useful command to get git infos.\nRequired node 10 or higher.\n\n## Prerequisites\n\nThe library is a wrapper around the `git` binary you have to install [git](https://git-scm.com/) before use this library.\n\n## Commands\n\n### Clone\n\nClone a remote repository\n\n```javascript\nconst { clone } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git clone https://github.com/ert78gb/git-utils-test.git /Users/User/git/git-utils-test\nawait clone({\n  url: 'https://github.com/ert78gb/git-utils-test.git',\n  cwd: '/Users/User/git/git-utils-test', // where to clone\n})\n```\n\n#### Options\n\n| parameter (type) | default value | description                                                              |\n| ---------------- | ------------- | ------------------------------------------------------------------------ |\n| url (string)     | empty         | HTTPS url of the remote repository                                       |\n| cwd (string)     | inherited     | Where to clone the remote repository. Inherited from the Node.js context |\n\n### Checkout Branch\n\nCheckout existing branch.\n\n```javascript\nconst { checkoutBranch } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git checkout \u003cbranch-name\u003e\nawait checkoutBranch({\n  branchName: 'my-branch',\n  cwd: 'path of the git repo',\n})\n```\n\n#### Options\n\n| parameter (type)    | default value | description                                                    |\n| ------------------- | ------------- | -------------------------------------------------------------- |\n| branchName (string) | empty         | Name of the branch that would like to checkout                 |\n| cwd (string)        | inherited     | Path of the git repository. Inherited from the Node.js context |\n\n## Get Current Branch\n\nCurrent branch name.\n\n```javascript\nconst { getCurrentBranchName } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git rev-parse --abbrev-ref HEAD\nconst branch = await checkoutBranch({\n  cwd: 'path of the git repo',\n})\n\nconsole.log(branch) // my-branch\n```\n\n#### Options\n\n| parameter (type) | default value | description                                                    |\n| ---------------- | ------------- | -------------------------------------------------------------- |\n| cwd (string)     | inherited     | Path of the git repository. Inherited from the Node.js context |\n\n## Get Current Sha\n\nThe current SHA1 hash.\n\n```javascript\nconst { getCurrentSha } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git rev-parse HEAD\nconst sha = await getCurrentSha({\n  cwd: 'path of the git repo',\n})\n\nconsole.log(sha) // dd064f731ce78a1dd64c41781c8bb01cfda9a6d8\n```\n\n#### Options\n\n| parameter (type) | default value | description                                                    |\n| ---------------- | ------------- | -------------------------------------------------------------- |\n| cwd (string)     | inherited     | Path of the git repository. Inherited from the Node.js context |\n\n## Get File Changes\n\nAll commit info of a file path.\nThe array is ordered by commit date in descending order.\n\n```javascript\nconst { getFileChanges } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git log --follow --no-decorate --date=iso8601-strict -- file-path\nconst commitInfos = await getFileChanges({\n  cwd: 'path of the git repo',\n  path: 'folder/file.path'\n})\n\nconsole.log(commitInfos)\n// [\n//   {\n//    sha: 'd3e89505291cb1d5881c6033d2ffd0abfc68fe10',\n//    author: 'Committer',\n//    date: 2021-02-08T16:19:42.000Z, // Commit date as Date\n//    message: 'fix: modify file'\n//   },\n//   {\n//    sha: '7f15cc49347592fbd60ea839f7e06be553965234',\n//    author: 'Committer',\n//    date: 2020-02-08T16:19:42.000Z, // Commit date as Date\n//    message: 'feat: create file'\n//   }\n// ]\n```\n\n#### Options\n\n| parameter (type) | default value | description                                                    |\n| ---------------- | ------------- | -------------------------------------------------------------- |\n| cwd (string)     | inherited     | Path of the git repository. Inherited from the Node.js context |\n| path (string)    |               | The path of the file from the repository root                  |\n\n## Get Commit Info\n\nThe latest commit info.\n\n```javascript\nconst { getCommitInfo } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git rev-parse HEAD\nconst info = await getCommitInfo({\n  cwd: 'path of the git repo',\n})\n\nconsole.log(info)\n// {\n//  sha: '7f15cc49347592fbd60ea839f7e06be553965234',\n//  author: 'Committer',\n//  date: 2020-02-08T16:19:42.000Z, // Commit date as Date\n//  message: 'feat: add b.txt\\n\\nBody of the comment'\n// }\n```\n\n#### Options\n\n| parameter (type) | default value | description                                                    |\n| ---------------- | ------------- | -------------------------------------------------------------- |\n| cwd (string)     | inherited     | Path of the git repository. Inherited from the Node.js context |\n\n#### Output\n\n```typescript\nArray\u003c{\n  sha:string,\n  author: string,\n  date: Date,\n  message: string\n  }\u003e\n```\n\n## Get Parent SHA\n\nQuery the parent shas of the latest commit or the provided SHA.\nIf a commit is a merge commit it has multiple parent\n\n```javascript\nconst { getParentShas } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git log --pretty=%P -1 7f15cc49347592fbd60ea839f7e06be553965234\nconst shas = await getCommitInfo({\n  sha: '7f15cc49347592fbd60ea839f7e06be553965234',\n  cwd: 'path of the git repo',\n})\n\nconsole.log(shas) // ['cde7266d8004b1391ce033fd86f0ffe4a1ce1793']\n```\n\n#### Options\n\n| parameter (type) | default value | description                                                                         |\n| ---------------- | ------------- | ----------------------------------------------------------------------------------- |\n| sha (string)     | empty         | SHA of the commit which parents you would like to get. You can use branch name too. |\n| cwd (string)     | inherited     | Path of the git repository. Inherited from the Node.js context                      |\n\n## Get Merge base\n\nGet the merge base of 2 sha or 2 branch\n\n```javascript\nconst { getMergeBase } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git merge-base 7f15cc49347592fbd60ea839f7e06be553965234 cde7266d8004b1391ce033fd86f0ffe4a1ce1793\n// git merge-base master feature-branch-name\nconst sha = await getMergeBase({\n  sha1: '7f15cc49347592fbd60ea839f7e06be553965234',\n  sha2: 'cde7266d8004b1391ce033fd86f0ffe4a1ce1793',\n  cwd: 'path of the git repo',\n})\n\nconsole.log(sha) // d3e89505291cb1d5881c6033d2ffd0abfc68fe10\n```\n\n#### Options\n\n| parameter (type) | default value            | description                                                                                              |\n| ---------------- | ------------------------ | -------------------------------------------------------------------------------------------------------- |\n| sha1 (string)    | empty                    | SHA or branch name which part of the merge                                                               |\n| sha2 (string)    | sha of the latest commit | SHA or branch name which part of the merge. The default value is the latest commit in the current branch |\n| cwd (string)     | inherited                | Path of the git repository. Inherited from the Node.js context                                           |\n\n## Get Changed Files\n\nGet the changed files of 2 sha or 2 commit\n\n```javascript\nconst { getChangedFiles } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git diff --name-status 7f15cc49347592fbd60ea839f7e06be553965234 cde7266d8004b1391ce033fd86f0ffe4a1ce1793\n// git dif --name-status master feature-branch-name\nconst changedFiles = await getChangedFiles({\n  sha1: '7f15cc49347592fbd60ea839f7e06be553965234',\n  sha2: 'cde7266d8004b1391ce033fd86f0ffe4a1ce1793',\n  cwd: 'path of the git repo',\n})\n\nconsole.log(changedFiles) // [ { action: 'added', path: 'b.txt' } ]\n```\n\n#### Options\n\n| parameter (type) | default value            | description                                                                                 |\n| ---------------- | ------------------------ | ------------------------------------------------------------------------------------------- |\n| sha1 (string)    | empty                    | SHA or branch name which part of the diff                                                   |\n| sha2 (string)    | sha of the latest commit | SHA or branch name which diff. The default value is the latest commit in the current branch |\n| cwd (string)     | inherited                | Path of the git repository. Inherited from the Node.js context                              |\n\n#### Output\n\n```Typescript\nArray\u003c{\n  action: string,\n  path: string\n}\u003e\n```\n\nValues of the actions\n\n- added\n- modified\n- deleted\n\n## Get Remote Tags\n\n```javascript\nconst { getRemoteTags } = require('@ert78gb/git-utils')\n\n// Equivalent git command\n// git ls-remote --tags https://github.com/ert78gb/git-utils-test.git org/feature/*\nconst tags = await getRemoteTags({\n  remote: 'https://github.com/ert78gb/git-utils-test.git',\n  prefix: 'org/feature/*',\n})\n\nconsole.log(tags) // Map { 'org/feature/v1.0.0' =\u003e 'cde7266d8004b1391ce033fd86f0ffe4a1ce1793', 'org/feature/v1.1.0' =\u003e '14630f2c65026f9bda22d6def4abd80ada6fcc6e' }\n```\n\n#### Options\n\n| parameter (type) | default value | description                                                                                                                |\n| ---------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------- |\n| remote (string)  | 'origin'      | URL of the remote git repo or alias remote of the local repo                                                               |\n| prefix (string)  | empty         | return only tags that match this pattern. If the \\* missing from the end of the string it will exact match not just prefix |\n| cwd (string)     | inherited     | Path of the git repository. Inherited from the Node.js context                                                             |\n\n#### Output\n\n```typescript\nMap\u003cstring, string\u003e // the key and the value also string.\n// The key is the tag name the value is the commit sha\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fert78gb%2Fgit-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fert78gb%2Fgit-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fert78gb%2Fgit-utils/lists"}