@babajide234/git-merge-workflow
v1.0.6
Published
Automated Git workflow for merging feature branches through staging to develop
Downloads
25
Maintainers
Readme
Git Merge Workflow PowerShell Module
Automate your git merge workflow with safety and ease. This module helps you merge your current feature branch to a staging branch (e.g., feature-branch-staging), and then to a target branch (e.g., develop), ensuring a consistent workflow.
Features
- Automated Merging: Merges current branch -> Staging -> Target.
- Safety Checks: Prevents running on wrong branches, checks for uncommitted changes.
- Conflict Handling: Stops immediately on merge conflicts so you can resolve them.
- Automatic Cleanup: Returns you to your original branch even if the script fails.
- Configurable: Define project-specific settings via a JSON configuration file.
- Dry Run: Support for
-WhatIfto preview actions.
Installation
Via NPM (Recommended for Node.js users)
You can install this tool globally using npm:
npm install -g @babajide234/git-merge-workflowThis will make the gmw and git-merge-workflow commands available in your terminal.
Manual Installation
- Download this repository.
- Run the included installation script:
Or copy the.\Install.ps1GitMergeWorkflowfolder to your PowerShell modules directory manually. - Import the module (if not auto-loaded):
Import-Module GitMergeWorkflow
Usage
Basic Usage
Run the workflow from your feature branch:
Invoke-GitMergeWorkflow
# OR use the alias
gmwWith Commit Message
If you have uncommitted changes, you can commit them as part of the workflow:
gmw -CommitMessage "Feat: Completed login page"Dry Run (Preview)
See what commands would be executed without actually running them:
gmw -WhatIfCustom Branches
Override default branches on the fly:
gmw -TargetBranch "main" -StagingBranch "custom-staging"Configuration
You can create a configuration file for your project so you don't have to pass parameters every time.
Navigate to your project root.
Run the configuration generator:
New-GitWorkflowConfig -TargetBranch "main" -StagingSuffix "-test"This creates a
.git-merge-workflow.jsonfile:{ "TargetBranch": "main", "StagingSuffix": "-test", "Remote": "origin" }
Publishing (For Maintainers)
GitHub Actions
This repository is configured to automatically publish to:
- PowerShell Gallery (if
NUGET_KEYsecret is set) - NPM Registry (if
NPM_TOKENsecret is set)
When you create a new Release in GitHub.
Manual Publishing
To NPM:
npm login
npm publish --access publicTo PowerShell Gallery:
Publish-Module -Path . -NuGetApiKey <Your-API-Key>Functions
Invoke-GitMergeWorkflow(Alias:gmw,git-merge-workflow): The main workflow command.New-GitWorkflowConfig: Generates the.git-merge-workflow.jsonconfiguration file.Get-GitWorkflowConfig: Reads the current configuration.
Cross-Platform Support (Mac/Linux)
This tool works on Windows, macOS, and Linux.
Requirements for macOS/Linux
You must have PowerShell Core (pwsh) installed.
macOS (Homebrew):
brew install --cask powershellLinux (Ubuntu):
sudo apt-get install -y wget apt-transport-https software-properties-common
wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershellLicense
MIT
