🍺 BREW Explorer

← all formulae

git-format-staged

brew install git-format-staged v4.0.1 MIT

Git command to transform staged files using a formatting command

729
30-day installs · #1477
1.9k
90-day · #1622
1.9k
365-day · #2863
245
★ GitHub stars · updated 2mo ago

Links

Raw metadata
{
  "aliases": [],
  "alternatives": [],
  "build_dependencies": [],
  "categories": [],
  "caveats": null,
  "conflicts_with": [],
  "dependencies": [],
  "deprecated": 0,
  "deprecation_reason": null,
  "desc": "Git command to transform staged files using a formatting command",
  "disable_reason": null,
  "disabled": 0,
  "enrichment_fetched_at": "2026-06-20T23:38:03+00:00",
  "first_seen": "2026-06-20T23:34:18+00:00",
  "full_name": "git-format-staged",
  "github_default_branch": "main",
  "github_last_commit_at": "2026-06-15T16:41:48Z",
  "github_readme_excerpt": "# git-format-staged\n\nConsider a project where you want all code formatted consistently. So you use\na formatting command. (For example I use [prettier][] in my Javascript and\nTypescript projects.) You want to make sure that everyone working on the project\nruns the formatter, so you use a tool like [husky][] to install a git pre-commit\nhook. The naive way to write that hook would be to:\n\n- get a list of staged files\n- run the formatter on those files\n- run `git add` to stage the results of formatting\n\nThe problem with that solution is it forces you to commit entire files. At\nworst this will lead to contributors to unwittingly committing changes. At\nbest it disrupts workflow for contributors who use `git add -p`.\n\ngit-format-staged tackles this problem by running the formatter on the staged\nversion of the file. Staging changes to a file actually produces a new file\nthat exists in the git object database. git-format-staged uses some git\nplumbing commands to send content from that file to your formatter. The command\nreplaces file content in the git index. The process bypasses the working tree,\nso any unstaged changes are ignored by the formatter, and remain unstaged.\n\nAfter formatting a staged file git-format-staged computes a patch which it\nattempts to apply to the working tree file to keep the working tree in sync\nwith staged changes. If patching fails you will see a warning message. The\nversion of the file that is committed will be formatted properly - the warning\njust means that working tree copy of the file has been left unformatted. The\npatch step can be disabled with the `--no-update-working-tree` option.\n\n[prettier]: https://prettier.io/\n[husky]: https://www.npmjs.com/package/husky\n\n## How to install\n\n### Install with Nix\n\nInstall via the CLI:\n\n    $ nix profile install github:hallettj/git-format-staged\n\nOr add to your flake imports, and use the `default` package output.\n\n### Install with NPM\n\nRequires Python 3.8 or later.\n\nInstall as a development dependency in ",
  "github_repo": "hallettj/git-format-staged",
  "github_stars": 245,
  "github_topics": [],
  "homepage": "https://github.com/hallettj/git-format-staged",
  "homepage_og_description": null,
  "homepage_og_image": null,
  "homepage_title": null,
  "installs_30d": 729,
  "installs_365d": 1942,
  "installs_90d": 1942,
  "keg_only": 0,
  "keg_only_reason": null,
  "last_seen": "2026-06-20T23:34:18+00:00",
  "license": "MIT",
  "llm_generated_at": null,
  "llm_model": null,
  "name": "git-format-staged",
  "oldnames": [],
  "one_liner": null,
  "optional_dependencies": [],
  "rank_30d": 1477,
  "rank_365d": 2863,
  "rank_90d": 1622,
  "raw_hash": "d97065fc30d8b98a",
  "recommended_dependencies": [],
  "revision": 0,
  "ruby_source_path": "Formula/g/git-format-staged.rb",
  "tap": "homebrew/core",
  "test_dependencies": [],
  "uses_from_macos": [
    "python"
  ],
  "version_head": "HEAD",
  "version_stable": "4.0.1",
  "versioned_formulae": [],
  "why_use_this": null
}