Sometimes we will find that we need to execute lots of git command to make a pull request. For example, if we need to make a pull request to merge feature/fa branch, we need to do:
# remove deleted origin branches git fetch -p origin # update main branch to avoid potential conflicts git switch main git pull --rebase origin main # update the current feature branch to avoid potential conflicts git switch feature/fa git rebase main # create pr gh pr create -f --base main # show current branch git branchThese steps are tedious. It's better that we can wrap these steps to one single command, and that is exactly what github-git-workflow does!
github-git-workflow uses script-launcher and github command cli gh, so you need to install gh firstly and then script-launcher.
Firstly, install gh, and make sure you have logged in.
Secondly, install script-launcher.
npm install script-launcher -DThen add start: launch to the package.json scripts section:
{..."scripts":{"start": "launch", ... }, ... }Then copy launcher-config.json to your project dir, in the same dir as your package.json file.
Github-git-workflow uses git topic branch, feature/_ branches for adding new features and hotfix/_ branches for fixing issues directly from main branch.
The life cyle of branches are create, finish and delete.
create: create the topic branch
finish: create the pull request from the topic branch, use this command to avoid potential conflicts
verify: if something wrong for pull request, after serveral commits you may fix the issue, then use verify to push local fix to remote topic branch to avoid potential conflicts
version: version command is used in main branch, after the pull request is approved, version command can be used to add version tag to the main branch.
delete: after pull request is merged to main branch, delete the local topic branch
Feature branch is operated using rebase as much as possible to solve potential conflicts in local topic branch before the pull request.
feature:nameCreate a feature topic branch named doc
npm start feature:docThen a new branch named feature/doc should be created.
* feature/doc mainfinish-feature:name # or for short ff:nameAfter all development and test, we can use finish command to creat the pull request.
npm start finish-feature:doc # or for short npm start ff:docThe command should create a pull request.
verify-feature:name # or for short vf:nameIf there's someting wrong with the pull request, and we fix the problem in local branch after several commits, then we can use verify command to push these commits to the remote branch of this pull request.
npm start verify-feature:doc # or for short npm start vf:docdelete-feature:name # or for short df:nameAfter the pull request is approved, we can use delete-feature command to delete the topic branch.
npm start delete-feature:doc # or for short npm start df:docHotfix branch is used to fix issues in released version. It doesn't use rebase, conflicts are solved in pull request.
hotfix:name:versionThis command create a branch named hotfix/name from the specific version tag, the version is a git version tag.
npm start hotfix:doc:v1.0.1After the command, a branch named hotfix/doc is created.
* hotfix/doc mainfinish-hotfix:name # or fh for short fh:nameThis command create a pull request from the topic branch.
npm start fh:docverify-hotfix:name # or vf for short vf:nameThe same as verify-feature, however, it doesn't rebase the topic branch from main branch.
npm start vf:docdelete-hotfix:name # or dh for short dh:nameThe same as delete-feature, to delete the hotfix branch after the pull request is approved.
npm start dh:docVersion command uses npm version to add tag go main branch.
If the version before executing the command is v1.0.0
npm start prepatch # v1.0.1-0npm start patch # v1.0.1npm start preminor # v1.1.1-0npm start minor # v1.1.1npm start premajor # v2.1.1-0# The recommand way is to use alpha or beta command rather than premajornpm start major # v2.1.1npm start alpha # v2.1.1-alpha.0npm start beta # v2.1.1-beta.0# or specify the preid npm start prerelease:omega # v2.1.1-omega.0# or specify the version# npm start version:semver npm start version:2.2.0 # v2.2.0