{"id":13998271,"url":"https://github.com/jez/git-madge","last_synced_at":"2025-04-13T08:22:36.138Z","repository":{"id":73797884,"uuid":"116893904","full_name":"jez/git-madge","owner":"jez","description":":rocket: Git-aware madge wrapper","archived":false,"fork":false,"pushed_at":"2018-01-14T03:09:15.000Z","size":636,"stargazers_count":66,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T00:11:10.940Z","etag":null,"topics":["cli","git"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/jez.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}},"created_at":"2018-01-10T01:54:07.000Z","updated_at":"2024-08-21T03:49:29.000Z","dependencies_parsed_at":"2023-03-25T11:17:08.448Z","dependency_job_id":null,"html_url":"https://github.com/jez/git-madge","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fgit-madge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fgit-madge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fgit-madge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jez%2Fgit-madge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jez","download_url":"https://codeload.github.com/jez/git-madge/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681702,"owners_count":21144738,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-08-09T19:01:31.616Z","updated_at":"2025-04-13T08:22:36.100Z","avatar_url":"https://github.com/jez.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# git-madge\n\n\u003e Git-aware madge wrapper\n\n[Madge] is tool for slicing and dicing the dependencies of your JavaScript\nproject. `git-madge` is a wrapper for [Madge] that makes it git-aware. This\nmeans that it understands what branch you're on, and only runs on those files\nthat have changed by this branch.\n\n[Madge]: https://github.com/pahen/madge\n\n`git-madge` can do two main things right now:\n\n- list files in order of their dependencies\n- draw a graph of dependencies\n\n![screenshot](screenshot-master.png)\n\nIf you're on a branch, the output gets limited to only those files that changed\nin this branch:\n\n![screenshot](screenshot-branch.png)\n\n(Note: we're rendering images in the terminal with iTerm2's `imgcat` program.)\n\n## Install\n\n### Dependencies\n\nRequires that `madge` and `jq` are on your path:\n\n```\nnpm install -g madge\nbrew install jq\n```\n\nIf you want to use any of the visual features, you'll also need `graphviz`:\n\n```\nbrew install graphviz\n```\n\nIf you're using iTerm2 and you want to display images in the terminal, install\n`imgcat`:\n\n\u003chttps://iterm2.com/documentation-images.html\u003e\n\n### Installation\n\nCopy the `git-madge` file to your path. Alternatively, using Homebrew:\n\n```\nbrew install jez/formulae/git-madge\n```\n\n\n## Usage\n\n```\n❯ git madge -h\nGit-aware madge.\n\nUsage:\n  git madge sorted [options] \u003cmadge option\u003e...\n  git madge dot    [options] \u003cmadge option\u003e...  \u003e  \u003cfilename\u003e.dot\n  git madge image  [options] \u003cmadge option\u003e...  \u003e  \u003cfilename\u003e.png\n\nOptions:\n  -b \u003cbranch\u003e, --base \u003cbranch\u003e  Limit madge to files changed by \u003cbranch\u003e. If on\n                                \u003cbranch\u003e, operate on all files in the repo.\n                                [default: master]\n  -s \u003cstyle\u003e, --style \u003cstyle\u003e   Use \u003cstyle\u003e when generating a graphviz image.\n                                Can be a preset or a path to a graphviz program\n                                that styles the graph. Available presets:\n                                black solarized-dark solarized-light white\n                                [default: white]\n  --dpi \u003cdpi\u003e                   Set the DPI of graphviz output to \u003cdpi\u003e.\n  -h\n\nMadge Options:\n  Madge requires at least a path in which to find JavaScript files.\n  You may also wish to configure things like webpack loaders.\n\n  Usage: madge [options] \u003csrc...\u003e\n\n  Options:\n\n    (... elided ...)\n```\n\n## Examples\n\n`git-madge` always works with respect to the current git branch that you're on.\n\n- If you're on master, it'll work with respect to the entire repo.\n- On a non-master branch, the commands apply to **only the files changed by that\n  branch**.\n\nTo list the entire repo's files sorted by dependency order:\n\n```\n~/demo (master)\n❯ git madge sorted .\nsrc/components/Provider.js\nsrc/utils/shallowEqual.js\nsrc/components/Elements.js\nsrc/components/inject.js\nsrc/components/PaymentRequestButtonElement.js\nsrc/components/Element.js\nsrc/index.js\n```\n\nChange to a branch, and the list gets shorter:\n\n```\n~/demo (my-branch)\n❯ git madge sorted .\nsrc/components/PaymentRequestButtonElement.js\nsrc/components/Element.js\nsrc/index.js\n```\n\nIf you want to filter with respect to a revision other than `master`, use\n`--base`:\n\n``` bash\n# only files changed by last commit:\n❯ git madge sorted --base HEAD^ .\n```\n\nYou can pass [any arguments that `madge` supports][flags], like webpack config,\nor paths:\n\n```bash\n# Custom webpack config\n❯ git madge sorted --webpack-config webpack.config.js\n\n# Limit to src/components/ folder\n❯ git madge sorted src/components/\n```\n\n[flags]: https://github.com/pahen/madge#cli\n\nLike `madge`, with `git-madge` you can create an image from the dependencies.\nAnd if you're on a non-master branch, the image shows nodes for only files\nchanged by this branch.\n\n```bash\n❯ git madge image . \u003e graph.png\n```\n\nAnother fun thing you can do (if you happen to use iTerm2) is show these images\ndirectly in your terminal with [imgcat]:\n\n```bash\n# FIRST: Download imgcat: https://iterm2.com/documentation-images.html\n\n❯ git madge image . | imgcat\n```\n\n[imgcat]: https://iterm2.com/documentation-images.html\n\n## Tips\n\nUse aliases to make the command invocation more convenient. Git lets you make\nper-project aliases, so you can stash the config options required by any given\nproject:\n\n```bash\ngit config alias.sorted  'madge sorted --basedir . --webpack-config webpack.config.js src'\n\n# another variant that excludes tests\ngit config alias.sortedt 'madge sorted --basedir . --webpack-config webpack.config.js --exclude \".*\\.test\\.js\" src'\n\n# show the dependency image\ngit config alias.depgraph 'madge image --basedir . --webpack-config webpack.config.js --exclude \".*\\.test\\.js\" src'\n```\n\nThen you can just do this:\n\n```\ngit checkout my-branch\ngit sorted\ngit depgraph | imgcat\n```\n\n## Styles\n\nAvailable stylesheets are in the [styles/](styles/) directory.\n\nFeel free to copy one, modify it, and contribute it back! Pull requests are very\nwelcome.\n\n## License\n\n[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://jez.io/MIT-LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjez%2Fgit-madge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjez%2Fgit-madge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjez%2Fgit-madge/lists"}