git-ninja

A powerful command-line tool designed to enhance your Git workflow with advanced commands tailored for developers.
It simplifies complex Git operations, making branch management and navigation more efficient and intuitive.
Screenshots
Recently used branches:

Frequently used branches:

Available Commands
branch:current - Work with the current branch
branch:exists - Check if the specified branch name exists
branch:freq - List branches frequently checked out
branch:last - Work with the last checked out branch
branch:recent - List branches recently checked out
branch:search - Search branch names for a substring or regex match
Examples
List recently checked out branches:
git-ninja branch:recent
List recently checked out branches, limit to 5 results and exclude 'develop' and 'main' from the list:
git-ninja branch:recent -c 5 -e 'develop|main'
Show the last checked out branch name:
git-ninja branch:last
Switch to the last checked out branch:
git checkout main
git checkout feature/my-feature
# switch from feature/my-feature to main:
git-ninja branch:last --checkout
Search for branches containing "fix":
git-ninja branch:search fix
Search for branches matching a regex pattern (e.g., all branches starting with GN-12):
git-ninja branch:search -r "GN-12.+"
Search for a substring in branch names, and check out the first result:
git checkout main
git-ninja branch:search some-fix -o
# our active branch is now "feature/some-fix" (assuming that was the first result)
Git Aliases - Configuration
Add the following aliases to your .gitconfig file to use git-ninja commands as Git aliases:
[alias]
# list recently checked out branches
lrb = "!f() { git-ninja branch:recent; }; f"
# list frequently checked out branches
lfb = "!f() { git-ninja branch:freq; }; f"
# search branches
sb = "!f() { git-ninja branch:search $@; }; f"
# push current branch
pcb = "!f() { git-ninja branch:current --push; }; f"
# switch to the last checked out branch
co-last = "!f() { git-ninja branch:last --checkout; }; f"
Git Aliases - Examples
List recently checked out branches:
git lrb
Search branch names:
# find branches containing "fix"
git sb fix
# find branches matching a regex pattern
git sb -r "fix.+"
# find branches containing "fix" and check out the first result
git sb fix -o
Switch to the last checked out branch:
git checkout main
git checkout feature/my-feature
git co-last # switch from feature/my-feature to main
Development Setup
go mod tidy
Building the project
git-ninja uses the task build tool. To build the project, run the following command:
task build
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.