A convenient Zsh script that provides shortcuts for creating standardized git commit messages with emoji prefixes and consistent formatting.
Run this single command to install and set up everything automatically:
bash -c "git clone https://github.com/ashsajal1/git-commit-shortcuts.git ~/.git-commit-shortcuts && cp ~/.git-commit-shortcuts/git-commit-shortcuts.zsh ~/.git-commit-shortcuts.zsh && echo 'source ~/.git-commit-shortcuts.zsh' >> ~/.zshrc && source ~/.zshrc && echo -e '\\n\\033[0;32mβ
Git Commit Shortcuts installed successfully! Run ghelp to see available commands.\\033[0m'"-
Copy the script to your home directory:
cp git-commit-shortcuts.zsh ~/.git-commit-shortcuts.zsh -
Add this line to your
~/.zshrc:source ~/.git-commit-shortcuts.zsh
-
Reload your shell configuration:
source ~/.zshrc
| Command | Emoji | Description |
|---|---|---|
gfeat |
β¨ | New feature |
gfix |
π | Bug fix |
gdocs |
π | Documentation changes |
gstyle |
π | Code style/formatting |
grefactor |
β»οΈ | Code refactoring |
gperf |
β‘ | Performance improvements |
gtest |
β | Adding or updating tests |
gchore |
π§ | Maintenance tasks |
gbuild |
ποΈ | Build system changes |
gci |
π | CI/CD configuration changes |
grevert |
βͺ | Revert previous commits |
greset |
π | Soft reset to previous commit (HEAD~1 by default) |
Soft reset to the previous commit (HEAD~1) or a specified commit:
# Reset to previous commit
greset
# Reset to a specific commit
greset abc123
# Reset 2 commits back
greset HEAD~2gfeat add login button
# Commits with message: "β¨ feat: add login button"
# With multi-word subject (use quotes)
gfix "resolve issue with user authentication"gdocs
# Will prompt: "Commit subject for π docs: "
# Type your subject and press EnterYou can add a detailed commit message body using pipes or file redirection:
# Using pipe
echo $'Detailed description\n\n- Added new API endpoint\n- Updated documentation' | gfeat implement user authentication
# Using file redirection
grefactor improve code structure < changes.txtghelp- The script automatically stages all changes (
git add -A) before committing. - To modify this behavior, edit the script and remove or change the
git addline. - All commit messages follow the format:
[EMOJI] type: subject
You can customize the commit types and their corresponding emojis by modifying the types_map array in the script.