Git Commit Shortcuts

November 3, 2025 ยท View on GitHub

A convenient Zsh script that provides shortcuts for creating standardized git commit messages with emoji prefixes and consistent formatting.

Installation

One-line installation

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'"

Manual Installation

  1. Copy the script to your home directory:

    cp git-commit-shortcuts.zsh ~/.git-commit-shortcuts.zsh
    
  2. Add this line to your ~/.zshrc:

    source ~/.git-commit-shortcuts.zsh
    
  3. Reload your shell configuration:

    source ~/.zshrc
    

Available Commands

CommandEmojiDescription
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)

Usage

Reset Command

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~2

Basic Usage (with subject)

gfeat add login button
# Commits with message: "โœจ feat: add login button"

# With multi-word subject (use quotes)
gfix "resolve issue with user authentication"

Interactive Mode (prompted subject)

gdocs
# Will prompt: "Commit subject for ๐Ÿ“ docs: "
# Type your subject and press Enter

With Multi-line Body

You 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.txt

View Available Commands

ghelp

Notes

  • The script automatically stages all changes (git add -A) before committing.
  • To modify this behavior, edit the script and remove or change the git add line.
  • All commit messages follow the format: [EMOJI] type: subject

Customization

You can customize the commit types and their corresponding emojis by modifying the types_map array in the script.