Package: git-genie
git-genie 🧞Generate & explain git commands using plain english.Generate commit messages based on staged changes❯git-geniecommit

Generatedcommand:gitcommit-m'Update README with commit message example and instructions'Generate & Explain complex git commands using plain englishInstallationpipinstallgit-genieUsage❯ git-genie [OPTIONS] INSTRUCTIONFor example:❯git-genie--explain"Who was the last person to modify the README.md file?"Options:--explain,-e: Explain the generated git command automatically.--execute,-x: Execute the generated git command automatically.--install-completion: Install completion for the current shell.--show-completion: Show completion for the current shell, to copy it or customize the installation.--help,-h: Show this message and exit.If no options are provided, the program will run in interactive mode.Optionally, you can add a "gg" alias to your shell's rc file (e.g. ~/.bashrc) to make the command shorter:aliasgg="git-genie"Pre-requisitesOpenAI API keyexportOPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxGenerate commit messagesGenerating commit messages is done by using thecommitcommand.
This method will create a concise message based on the changes staged for a commit.❯gitstatus

Changestobecommitted:(use"git restore --staged <file>..."tounstage)modified:README.mdLet's generate a commit message for the changed README.md file:❯git-geniecommit
Generatedcommitcommand:gitcommit-m'Update README with commit message example and instructions'(E)xplainore(X)ecuteor(N)ew?:XBy pressingX, the generated commit command will be executed automatically:Runningcommand:gitcommit-m'Update README with commit message example and instructions'Output:[commit_gen75d69ce]UpdateREADMEwithcommitmessageexampleandinstructions1filechanged,19insertions(+)Interactive modeBy default, the program will run in interactive mode, where it will ask you if you would like to explain the generated
git command, execute it, or generate a new command.~/git-genie❯git-genie"count how many times the README.md file was modified in the last week"Generatedgitcommand:gitlog--since=1.week--README.md|grep"^commit"|wc-l(E)xplainore(X)ecuteor(N)ew?:E

Explanationgitlog->Showcommitlogs
--since=1.week->Showcommitsmorerecentthanaspecificdate
--README.md->OnlycommitsthataffectREADME.md|->Pipetheoutputofthepreviouscommandtothenextcommandgrep"^commit"->Onlyshowlinesthatstartwith"commit"wc-l->Countthenumberoflines

e(X)ecuteor(N)ew?:X

Runningcommand:gitlog--since=1.week--README.md|grep"^commit"|wc-l
Output:2Non-interactive modeExplainBy using the--explainflag, the program will print the explanation of the generated git command.~/git-genie❯git-genie"amend all previous commits with new email address"--explain

Generatedgitcommand:gitrebase-iHEAD~5--autosquash-m"legacy code"Explanationgitrebase->Forward-portlocalcommitstotheupdatedupstreamhead
-i,--interactive->Makealistofthecommitswhichareabouttoberebased.Lettheusereditthatlistbeforerebasing.
--autosquash->Automaticallymovecommitsthatbeginwithsquash!/fixup!tothebeginningofthetodolist.
-m,--merge->Usethegivenmessageasthemergecommitmessage.Ifmultiple-moptionsaregiven,theirvaluesareconcatenatedasseparateparagraphs.
HEAD~5->Thelast5commits
legacycode->ThemessageofthemergecommitExecuteBy using the--executeflag, the program will execute the generated git command automatically without asking for
confirmation.~/git-genie❯git-genie"print last 5 commits logs, condensed"--execute

Generatedgitcommand:gitlog-5--oneline

Runningcommand:gitlog-5--oneline

Output:
9a33bc3updateemail
f76f041CLIinterface
ae8abbdAddpycachetogitignore
67169fdrichprint
3bac238Refactor