git-auto-rebase-cli
v1.3.1
Published
A CLI tool that provides git automation commands including auto-rebase and amend-push functionality
Maintainers
Readme
git-auto-rebase-cli
A CLI tool that provides git automation commands including auto-rebase and amend-push functionality.
Installation
npm install -g git-auto-rebase-cliUsage
In any git repository directory, run:
Auto Rebase (default)
git-auto-rebase
# or explicitly
git-auto-rebase rebaseAmend and Push
git-auto-rebase amend
# or
git-auto-rebase amend-pushCommit and Auto Rebase
git-commit-auto-rebase "your commit message"Auto Commit and Push
# First, stage your changes
git add .
# Auto generate commit message and push
git-auto-commit-push
# Or use custom commit message
git-auto-commit-push "your commit message"
# Or use the short alias
gacp "your commit message"
gacp # Auto generate commit messageHelp
git-auto-rebase --help
# or
git-auto-rebase -hWhat it does
Auto Rebase Command (rebase)
- Checks if you're in a git repository
- Verifies working directory is clean (no uncommitted changes)
- Gets current branch name
- Switches to main branch
- Pulls latest changes from origin/main
- Switches back to your original branch
- Rebases your branch onto main
- Pushes changes with
--force-with-lease
Amend and Push Command (amend)
- Checks if you're in a git repository
- Gets current branch name
- Prevents execution on main branch for safety
- Amends the last commit without editing the message (
git commit --amend --no-edit) - Pushes changes with
--force-with-lease
Commit and Auto Rebase Command (git-commit-auto-rebase)
- Checks if you're in a git repository
- Gets current branch name
- Prevents execution on main branch for safety
- Commits changes with provided message (
git commit -m "message") - Pushes changes to remote (
git push) - Switches to main branch
- Pulls latest changes from origin/main
- Switches back to your original branch
- Rebases your branch onto main
- Pushes changes with
--force-with-lease
Auto Commit and Push Command (git-auto-commit-push)
- Checks if you're in a git repository
- Gets current branch name
- Checks if there are staged changes
- Auto-generates commit message based on staged files (or uses provided message)
- Commits changes (
git commit -m "message") - Pushes changes to remote (
git push)
Note: You need to manually run git add before using this command.
Help Command (--help)
Displays usage information including:
- Available commands and their descriptions
- Usage examples
- Safety features overview
Requirements
- Node.js >= 12.0.0
- Git repository
- Clean working directory (no uncommitted changes)
Safety Features
- Checks for uncommitted changes before proceeding (rebase command)
- Uses
--force-with-leasefor safer force pushes - Prevents amend-push on main branch for safety
- Error handling with clear messages
- Exits gracefully if not in a git repository
Example Output
Auto Rebase
Starting git auto rebase...
Current branch: feature-branch
Checking if working directory is clean...
Switching to main branch...
Pulling latest changes from main...
Switching back to feature-branch branch...
Rebasing feature-branch onto main...
Pushing changes with force-with-lease...
Git auto rebase completed successfully!Amend and Push
Starting git amend and push...
Current branch: feature-branch
Amending last commit without editing message...
Pushing changes with force-with-lease...
Git amend and push completed successfully!Commit and Auto Rebase
Starting git commit auto rebase...
Current branch: feature-branch
Committing changes with message: "feat: add new feature"
Pushing changes...
Starting git auto rebase...
Current branch: feature-branch
Switching to main branch...
Pulling latest changes from main...
Switching back to feature-branch branch...
Rebasing feature-branch onto main...
Pushing changes with force-with-lease...
Git auto rebase completed successfully!Auto Commit and Push
Starting auto commit and push...
Current branch: feature-branch
Generating commit message...
Generated message: "update src/index.js, src/utils.js"
Committing changes...
Pushing to remote...
Auto commit and push completed successfully!Help Output
git-auto-rebase-cli v1.3.1
Usage:
git-auto-rebase [command]
git-commit-auto-rebase <commit message>
git-auto-commit-push [commit message]
Commands:
git-auto-rebase [command]
rebase Automatically rebase current branch onto main (default)
amend Amend last commit and force push with --force-with-lease
amend-push Same as amend
--help, -h Show this help message
git-commit-auto-rebase <commit message>
Commit staged changes with message, push, then auto rebase onto main
Note: Cannot be used on main branch
git-auto-commit-push [commit message]
Auto commit staged changes and push to remote
If no message provided, automatically generates commit message based on changes
Examples:
git-auto-rebase # Run auto rebase (default)
git-auto-rebase rebase # Run auto rebase explicitly
git-auto-rebase amend # Amend last commit and push
git-auto-rebase --help # Show this help
git-commit-auto-rebase "fix: bug fix" # Commit with message, push, then rebase
git-auto-commit-push "feat: new feature" # Commit and push with message
git-auto-commit-push # Auto generate commit message and push
Safety Features:
- Prevents amend/push operations on main branch
- Uses --force-with-lease for safer force pushes
- Checks for clean working directory before rebase
- Comprehensive error handlingLicense
MIT
