What is Workflow?
Workflow is an abstract and general description of the Workflow and the business rules between each operation step [1]. The right choice and use of a workflow can make technical team development more efficient and easier!
How do I choose a Workflow?
Recommended reading: Big talk about Git workflow
Workflow has no silver bullet [2] if your:
- Gitflow can be used in production environments that have multiple versions and need to continuously support older versions of software services such as operating systems, custom applications, etc
- The production environment has only one version, such as a website, network service, and so on. Feature Branch Workflow can be used
- The production environment only has one version but the software is very complex, which requires CI/CD to enter the production environment, such as Gmail, Twitter, etc., can use Gitlab-Flow
What is Feature Branch Workflow?
The core idea of Feature Branch Workflow is that the Master Branch is used for deployment, Feature development should be on a dedicated Branch, not the Master Branch, and any feature-branch pushed to the Master Branch should be reviewed by code. That is, team members share a private project repository for management collaboration, developers develop in their own feature-branch, and then submit Merge Request for code review. Merge into the Master branch after code review (ready for deployment to production).
A Merge Request is a Request for other project members to review and Merge code. Similar to GitHub’s Pull Request, both implement the merging of two repOS or branches. Coding.net provides a friendly Merge Request interface that allows you to review submitted changes before merging them into a formal project.
Feature Branch Workflow Workflow
Let’s look at a simple example of how Feature Branch Workflow works.
Onion monkey develops a new feature
Onion Monkey needs a separate branch to work on before it can develop features. He creates a new branch named banana based on the master branch using the following command:
git checkout -b banana master
Copy the code
On the new branch, onion Monkey implements the new functionality by editing, staging, and submitting changes in the usual way:
git status
git add
git commit
Copy the code
Onion monkey is going to eat a banana
Submit the code to a remote central repository before dinner, so that it can be easily backed up and other friends can see onion Monkey’s submission.
git push -u origin banana
Copy the code
Onion Monkey completed the development of new features
Onion Monkey completes this feature and initiates a Merge Request on the Coding.net project Merge Request page, requesting the Merge banana branch to the Master branch, and its team members are automatically notified. The Merge Request interface provided by Coding.net allows team members to comment alongside relevant code, making it easier to ask questions about changes.
Git push origin banana: Mr/Master /banana can simultaneously push banana branches and automatically initiate Merge Ruquest
The grand Saint received a Merge Request
Merge Request is received and code review is performed. He will decide whether to change it before merging it into the Master branch and discuss it with Onion Monkey via Merge Request.
Onion Monkey fixes it again
As before, Onion Monkey did some editing, staging, and submission again.
git add
git commit
git push -u origin banana
Copy the code
These changes are automatically updated to the Merge Request, and the Master can continue to do code reviews to initiate discussions on his specific code. Of course, the great Saint can also pull the banana branch to local modification. Any changes he submits will also show up in the Merge Request.
Release new features
Once the grand Sage agrees (this +1) and the tests (if any) pass, merge can be performed. Onion Monkey (or the Great Saint) can be merged directly by clicking “Merge” on the Coding.net web page or by using the following command:
git checkout master
git pull
git pull origin banana
git push
Copy the code
This process often produces a merge commit. Some developers like this because it acts like a link between the new feature and the original code baseline. But if you prefer a linear commit history, you can branch the rebase function to the top of the master branch when performing a merge, resulting in a fast-forward merge.
- When a branch is merged, it can be deleted.
- In order to prevent other members from misoperation, developers can also use the branch protection function of Coding.net to protect code branches.
- Rebase is often used to avoid/resolve conflicts.
Happy Coding ; )
Workflow technology [2] [1] zh.wikipedia.org/wiki/ stackoverflow.com/a/35915110