git-pr-helper v1.1.1
git-pr-helper
This tool helps manage git branches when using three long-lived develop, staging and release branches.
The GitHub CLI needs to be installed on your computer first, as this is how the PRs are created.
Usage
npx git-pr-helper <command>I recommend setting up a git alias to avoid having to type npx git-pr-helper every time. Add the following to your .gitconfig file:
[alias]
pr-helper = !npx git-pr-helper $@Commands
init
This is required before running any other command. It will ask some basic questions related to your branching setup.
Throughout this guide, I will refer to the three branches as develop, staging and release, even though it may differ slightly in your project.
create <name>
This will create a new branch based on the name. This must start with either feature/, bugfix/ or hotfix/. Features and bugfixes will come off develop, whereas hotfixes will come off release.
finish [name] [--staging]
This will do different things depending on whether the branch is a feature, bugfix or hotfix branch. By default this will work with the current branch; you can alternatively provide a branch name.
If it is a feature or hotfix:
- This will create a PR from the feature branch to
develop. It will then move you back todevelop. - If the
--stagingflag is provided, it will create a PR forstagingas well asdevelop.
If it is a hotfix:
- It will create a PR from the hotfix branch to
release. - It will then create a PR from the hotfix branch into
developandstaging. - Finally, it will move you back to
release.
promote develop
This will create two PRs:
- First,
releasetodevelop, which should be merged first. - Then
developtostaging.
promote staging
This will create a PR from staging to release.