Skip to content

LouisB06/GitGood

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GitGood

I kept writing "fix stuff" and "updates" as commit messages and it was getting embarrassing. So I built this. You run gg inside any git repo and it reads your staged diff and writes a proper conventional commit message for you. No API key needed, no account, nothing. It just works.

It pulls function names straight out of your code, figures out whether something is a feat or a fix or a refactor based on what actually changed, and formats it properly. It also does a bunch of other stuff I kept needing like standup summaries, PR descriptions and finding which commit broke something.

Built this as a side project to scratch my own itch. Probably useful if you feel the same way about commit messages as I do.


Requirements

Node 18 or higher. Git. That's it. Works on macOS and Linux.


Installation

If running npm install -g asks for sudo on your machine you'll want to set a user prefix first:

mkdir -p ~/.npm-global
npm config set prefix ~/.npm-global

Then add this to your ~/.zshrc or ~/.bashrc:

export PATH="$HOME/.npm-global/bin:$PATH"

Reload your shell:

source ~/.zshrc

Then install:

npm install -g gg-commit

Done. Run gg inside any git repo.


Commands

gg

The main one. Stage your files, run gg, and it generates a commit message. Press enter to commit, r to get a new one, e to edit it yourself, q to quit.

git add .
gg

gg tag

Looks at your recent commits and works out whether the next release should be a patch, minor or major bump. Creates the tag and pushes it.

gg revert

Shows your last 15 commits as a numbered list. Pick one and it reverts it.

gg undo

Undoes your last commit but keeps all the changes unstaged. Useful when you committed something too early.

gg log

A readable commit graph with colours. Much easier to scan than the default git log output.

gg status

Shows staged, modified and untracked files separately with counts. Cleaner than git status.

gg bisect "description"

You describe a bug in plain English and it searches through your commit history to find which commits are most likely responsible. Uses git's pickaxe search under the hood so it's actually looking through code changes, not just commit messages. Pick a result to see the full diff.

gg bisect "login not working"
gg bisect "payment function"

gg recap

Generates a standup summary from your commits. Defaults to today. Pass week or month for a longer window. Press c to copy it straight to your clipboard.

gg recap
gg recap week
gg recap month

gg why <file or function name>

Traces back through git history to show you when something was first added and who added it. Really useful when you find code that makes no sense and want to know why it exists.

gg why src/auth/jwt.js
gg why validateToken

gg watch

Runs in the background and sends you a notification if you have had uncommitted changes for over an hour. Stops you doing 6 hours of work in one massive commit.

gg watch

Press ctrl+c to stop it.

gg pr

Generates a PR title and description from all the commits on your current branch. Press c to copy it to clipboard or g to open GitHub directly.

gg explain <hash>

Breaks down any commit in detail. Shows who made it, what files changed, how many lines were added and removed.

gg explain abc1234

gg help

Lists all commands and shows the welcome screen again.


How the commit message is generated

No AI involved at all. It is pure pattern matching on your diff.

It scans the added lines for function and method definitions and pulls out the names. It looks at the file types and the ratio of lines added to removed to decide on a type (feat, fix, refactor, chore, docs, test). It finds the deepest common folder across your changed files to use as a scope. Then it builds the message from whatever it found.

It is not going to be perfect every time but it is a solid starting point and takes about half a second.


Licence

All rights reserved. See the LICENSE file. If you want to use this in something get in touch.

Built by Louis Blake

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors