My own understranding of Gitflow. How to use Gitflow when developing projects within a team?

Git-flow is for better cooperation with others in some big projects.

There are two common branches: master and develop.

The first one master branch is for releasing projects when reaching a new version. Mostly, every commit of master branch is a single version with a tag illustrating its version.

The second one develop branch is for developing. When it finish some important development, this branch will be merged into master branch (through a release branch) and make a new version of release.

Those two branches are visible on remote, which also known as origin in git. And they will both exist for a lifelong time.

Besides those two branches, there are some branches that will not exist on origin, but will exist locally, which are also known as supporting branches, they are:

  • Feature branches;
  • Release branches;
  • Hotfix branches;

Those branches have a shorter life time. They usually are deleted after being merged into other branches.

Feature branches

A feature branch may be off from develop branch, and must be back into develop branch. Its name can be anything illustrating the feature, except: master, develop, release-*, or hotfix-*.

A feature branch’s life time is like the figure below:

Once it has been merged into develop, it will be deleted.

Those commands are commonly used during a feature branch’s lifetime:

# create a new feature branch from develop
git checkout -b myfeature develop
# add some commits and finish a feature...

# switch to develop branch and merge feature branch into develop branch
git checkout develop
git merge --no-ff myfeature

# after merged into develop branch, the feature branch's life time is over
git branch -d myfeature

# at last we push develop to origin
# git push <remote-url> <local-branch>[:remote-branch]
git push origin develop

The --no-ff is important. This option will creating a commit all the times, even if this can be performed with a fast-forward. This will make sure that the information that there once was a feature branch always be in the commits.

This feature branch makes more clearly compared with committing on the develop branch directly (There will always one commit for every feature):

In the latter one, it is also convenient for reverting between features.

Release branches

A release branch may be off from develop branch, must be back into develop and master branch.

Its name must be looked like: release-*.

A release branch is to prepare the release of a new version. Mostly, there will only be one release branch related to the next version. This branch is created when all the feature of next version are implemented.

Creating this release branch is mainly for update some version information. Once this branch is created, bug fixed may be applied in this branch rather than develop branch. Adding new large features is prohibited by this branch, those features must be merged into devolop branch waiting next release branch to release.

After finishing the version information updates, this release branch can be merged into master and you should add a tag for the master branch to illustrate the version information.

Of course, this release branch should be merged into develop branch to make sure the changes be kept by the develop branch. There may be some conflicts, you need fix them and make a commit.

Finally, the release branch can be deleted.

Those commands are used during a release branch’s life time:

# new version 1.2 will be released
git checkout -b release-1.2 develop

# update the version information on the release-1.2 branch...

# commit the version information updates
git commit -a -m "Bump to version 1.2"

# there may be some bug fixes be apllied to the release branch

# now we make sure to release a new version, merge this branch to master
git checkout master
git merge --no-ff release-1.2
git tag -a 1.2

# to keep the changes made in the release branch, we need to merge it into develop branch
git checkout develop
git merge --no-ff release-1.2

# now we can delete the release branch
git branch -d release-1.2

The --no-ff option is still necessary, which will enable us to see the new version.

Hotfix branches

A hot-fix branch may be off from master branch, and must be back into develop and master branches. Its name is looked like: hotfix-*.

This hot-fix branch is similar with release branch, the only difference is that this branch is to fix a bug which need to be fixed immediately, and this branch will increase the minor version number by one.

The figure below illustrates how to use a hot-fix branch to fix a critical bug:

Those commands are used during the hot-fix life time:

# someone reported a new critical bug, we must fix it quickly.
git checkout -b hotfix-1.2.1 master

# we must update version information first, and create a commit to illustrate this.
git commit -a -m "Bumped version number to 1.2.1"

# then fix the bug, after that create a commit.
git commit -m "Fix a severe production problem."

# merge this branch into master
git checkout master
git merge --no-ff hotfix-1.2.1
git tag -a 1.2.1

# merge this branch into develop, if there is no release branch
# otherwise, merge this branch into the release branch rather than develop branch
git checkout develop
git merge --no-ff hotfix-1.2.1

# delete the hotfix branch
git branch -d hotfix-1.2.1

The --no--ff option is still necessary, and notice that you should merge this branch into a release branch if there is one, unless the develop branch immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into the develop branch.

Summary

The whole git flow with all these branches:

References

  1. A successful Git branching model
  • 21
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
To put your own Python module into the `sys.path` of a Conda environment, you can follow the steps below: 1. Activate the Conda environment where you want to add the module to the `sys.path`. You can do this by running the following command: ``` conda activate <env_name> ``` Replace `<env_name>` with the name of your Conda environment. 2. Navigate to the directory that contains your Python module. 3. Find out the exact path of the directory containing your module. You can do this by running the following command in the terminal: ``` pwd ``` This will display the path to the current directory. 4. Open a Python interpreter by running the `python` command in the terminal. 5. Import the `sys` module and append the path to your module directory to the `sys.path` list. You can do this by running the following commands in the Python interpreter: ``` import sys sys.path.append('/path/to/your/module/directory') ``` Replace `/path/to/your/module/directory` with the actual path to your module directory. 6. Verify that the module is now available in the `sys.path` of the Conda environment by running the following command in the Python interpreter: ``` import <module_name> ``` Replace `<module_name>` with the name of your module. If there are no errors, your module should now be available for use in the Conda environment. Keep in mind that this method only adds the module to the `sys.path` of the current session, so you will need to repeat the steps above each time you start a new terminal session and want to use the module. To make the module permanently available in the Conda environment, you should consider creating a Python package and installing it using `pip` or `conda`.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值