https://github.com/permafrost-dev/git-ninja
Advanced git commands for developers
https://github.com/permafrost-dev/git-ninja
cli developer-tools git git-commands
Last synced: 5 months ago
JSON representation
Advanced git commands for developers
- Host: GitHub
- URL: https://github.com/permafrost-dev/git-ninja
- Owner: permafrost-dev
- License: mit
- Created: 2023-11-11T15:42:23.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-19T02:23:42.000Z (5 months ago)
- Last Synced: 2024-11-19T03:24:28.801Z (5 months ago)
- Topics: cli, developer-tools, git, git-commands
- Language: Go
- Homepage:
- Size: 324 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# 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
- `checkout` - Check out a branch## Examples
Check out, then `git pull` the `main` branch:
```bash
git-ninja checkout main --pull
git-ninja co main -p
```List recently checked out branches:
```bash
git-ninja branch:recent
```List recently checked out branches, limit to 5 results and exclude 'develop' and 'main' from the list:
```bash
git-ninja branch:recent -c 5 -e 'develop|main'
```Show the last checked out branch name:
```bash
git-ninja branch:last
```Switch to the last checked out branch:
```bash
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":
```bash
git-ninja branch:search fix
```Search for branches matching a regex pattern (e.g., all branches starting with `GN-12`):
```bash
git-ninja branch:search -r "GN-12.+"
```Search for a substring in branch names, and check out the first result:
```bash
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:
```ini
[alias]
co = "!f() { git-ninja checkout $@; }; f"
# 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:
```bash
git lrb
```Search branch names:
```bash
# 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
# or checkout a branch by ticket number:
git sb -o 1123 # checks out 'GN-1123-my-feature-branch'
```Switch to the last checked out branch:
```bash
git checkout main
git checkout feature/my-feature
git co-last # switch from feature/my-feature to main
```## JIRA Integration
The `branch:recent` command can be run with the `--jira` flag to slightly modify the ordering of the results based on open issues in JIRA. Assuming your branches contain
the JIRA issue key in the branch name, the command will rank branches with open issues that have been updated recently slightly higher in the list.Tickets with a higher numerical suffix and have been recently updated are ranked slightly higher in the list,
while tickets that have not been updated recently are ranked lower.```bash
git-ninja branch:recent --jira
```To enable the JIRA integration, set the `JIRA_API_TOKEN`, `JIRA_SUBDOMAIN` and `JIRA_EMAIL_ADDRESS` environment variables.
## Development Setup
```bash
go mod tidy
```### Building the project
`git-ninja` uses the [task](https://github.com/go-task/task) build tool. To build the project, run the following command:
```bash
task build
```---
## Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.
## Contributing
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.
## Security Vulnerabilities
Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
## Credits
- [Patrick Organ](https://github.com/patinthehat)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.