According to the Git Flow workflow, feature branches and bug fixes will be merged into develop
via pull requests.
Install:
apt-get install git-flow
Init:
Git Flow will ask us a series of questions from the terminal, we will answer by default (simply by pressing enter) each and every one of them.
If we want to avoid this step, using the -d flag all default configurations will be established.
git flow init
Example:
Which branch should be used for bringing forth production releases?
- develop
- master
Branch name for production releases: [master]
Which branch should be used for integration of the "next release"?
- develop
Branch name for "next release" development: [develop]
How to name your supporting branch prefixes?
Feature branches? [feature/]
Bugfix branches? [bugfix/]
Release branches? [release/]
Hotfix branches? [hotfix/]
Support branches? [support/]
Version tag prefix? []
Hooks and filters directory? [/Users/your-user/Sites/your-dirname]
By default, master will be our main branch, develop will be our development branch, new feature branches will be prefixed with feature/, branches to fix small bugs that have not reached production will be prefixed with bugfix/, branches to put Code in production will be prefixed with release/, bugfix branches in production will be prefixed with hotfix/, and support branches will be prefixed with support/.
When we are going to develop a new feature, or evolve/modify an existing one, we will use feature branches.
For this Git Flow offers us the git flow feature command.
feature:
List existing feature branches
git flow feature
Start:
Create a feature branch. The name is mandatory (the prefix "feature/" will be automatically added), the base is optional and would allow us to create the feature from a specific branch. If it is not indicated, the default is developed
git flow feature start <name> [<base>]
Publish:
Upload the branch to the remote repository
git flow feature publish <name>
Finish and Delete:
They are replaced by merge request using GitLab
Track:
Used to track a feature branch that was created by another user on the team. This is useful when you are collaborating on a feature and want to sync your local repository with the remote version of that feature branch.
git flow feature track <name>
If a bug is detected that has not yet reached production, we will make a bugfix.
For this Git Flow offers us the git flow bugfix command.
Bugfixes will be merged against develop.
bugfix:
List existing bugfix branches
git flow bugfix
Start:
Create a bugfix branch. The name is required (the prefix "bugfix/" will be automatically added,
The base is optional and would allow us to create the bugfix from a specific branch.
If not indicated, the default is developed
git flow bugfix start <name>
Publish:
Upload the branch to the remote repository
git flow bugfix publish <name>
Finish and Delete:
They are replaced by merge request using GitLab
We use commit messages to automatically generate the changelog and version, so it is important that you follow the conventional commits guidelines.
Commitlint is a tool that allows us to validate the commit messages, and thus be able to standardize them.
It is based on a configuration file, which is usually called commitlint.config.js, and in which we can define the rules that we want to apply to the commit messages.
Install:
npm install -g @commitlint/cli @commitlint/config-conventional
Branch lint is a tool that allows us to validate the branch names, and thus be able to standardize them.
It is based on a configuration file, which is usually called .branchlintrc, and in which we can define the rules that we want to apply to the branch names.
Install:
npm install -g branchlint
What Husky is based on is Git Hooks, which are scripts that are executed at certain times, such as before a commit, push, etc...
Husky allows us to configure these hooks in a very simple way, and also allows us configure them in the package.json, which allows us to have a more portable project.
Install:
npm install -g husky
npx husky install
Add hook for commitlint:
npx husky add .husky/commit-msg 'commitlint --edit ${1}'
npx husky add .husky/pre-push 'branchlint'
Main Tasks:
task | Description |
---|---|
npm run test |
Run all tests. |
npm run release |
Create a new release. |
Subs Tasks:
task | Description |
---|---|
npm run lint |
Run the linter. |
npm run build |
Build the project. |
npm run dist |
Build the project and create a prepare nuw distribution. |
npm run docs |
Generate the documentation. |
- Git flow
- Gitflow workflow
- tutorial -Conventional Commits
- conventional commits
- Conventional Commits in 6 steps