Simple Flow To Release A Branch On Git

GIT
By bhagwatchouhan
Simple Flow To Release A Branch On Git

This post explains the git commands required to release dev branch on Git without using gitflow. It assumes that the project has separate branches for master(release) and development. It's the easiest and preferred git-flow to manage daily commits on Git where we commit on daily basis on the Dev Branch and then merge it with the Master Branch also called as Release Branch while releasing the project.

 

In more complex scenarios, we might also need to maintain release branches for backward compatibility. In such cases, a separate branch must be made for Major or Minor release based on the release plan. The regular development will be done on the dev branch and the changes will be merged with release and master branches according to the feature plan.

 

Below listed are all the commands required to make a release by merging the Dev Branch to Master Branch and then tagging the Master Branch.

 

Check available branches

 

First of all, check all the available branches as shown below.

 

# Make sure that the dev branch is active
git branch -v

# The active branch will be prefixed by an asterisks and the name will be in green color

 

Rebase the Dev Branch

 

Rebase the Dev Branch from remote assuming that all the code is already committed on the remote server.

 

# Rebase from remote server to sync the local branch
git pull --rebase <remote> dev

# Example - Rebase from origin
git pull --rebase origin dev

 

Merge with Master

 

Merge the Dev Branch with Master Branch and push it on the remote server.

 

# Checkout Master
git checkout master
# Merge Dev with Master

# Merge with comments
git merge dev --no-ff

OR

# Merge without comments
git merge dev --no-ff --no-edit

# Push master to remote
git push origin master

 

Add Release Tag

 

Now add a tag with the appropriate message and then push the tag to master. In this way, we are tagging the current project and making a release by specifying the release name as the tag name.

 

# Tag the Project with release name and message
git tag -a <Tag/Release Name> -m "<Release message>"

# Example
git tag -a 1.0.0-alpha1 -m "Releasing Alpha 1 of version 1.0.0"

# Push the Tag to Remote
git push origin 1.0.0-alpha1

# Back to work - Checkout Dev Branch
git checkout dev
# Now continue on Dev Branch till next release

 

 

This is how we can release a project by following the most generic approach.

 

share on :

Profile picture for user bhagwatchouhan
bhagwatchouhan