Learning Git-flow!

Publish date: Apr 10, 2021
Tags: Efficiency Tools

img

Hands-on Git-flow

Git-flow bundles Git commands into work flows so that we can easily use version control.

First, I initiate a repository named test-git-flow and push my test file to the repo.

image-20210425111646362

image-20210425112448326

Then init the git flow in this project.

image-20210425112613103

This step actually commits nothing.

New Features

Now create a new branch to add new features.

image-20210425112942185

After adding new features to the test file, I finished the new feature. But I need to run git push before git flow finish, or the github won’t update the new branch feature/rss-feed. So does the develop branch.

image-20210425113534784

image-20210425113621986

After finishing the feature, the branch will be automatically deleted from GitHub and merged into development branch.

Bug fixing

image-20210425113949875

The “line” is misspelled in both main and develop branched. Now I will try hot fix commands.

image-20210425115856440

image-20210425115308135

The bug has been fixed in the hotfix branch. Then finish this fixing.

image-20210425115817104

Then the hotfix branch has been merged into master and developement branches and deleted.

The git flow operation violates atomicity. It merge hotfix into master first, then dev.

[2021.05.13 Updated] Learn git rebase

git pull = git fetch + git merge.

Git merge operation does not save the history of commits. it’s better to use git fetch + rebase.

Do note that after fetching a remote repository/branch, we should rebase based on “origin/**” branch.

“git branch” will show the difference.