Version Control – Not so obvious

Version control is propably a known concept to almost every programmer. However, it is not that obvious how to handle or keep track of your changes.

May 30, 2018

In my previous post I wrote a little introduction about DevOps and how I want to get more into it. It has been a while since I got started with the topic and now some results are coming up. Therefore I want to share my first insights. With this post, I want to describe git-flow.

 

Git-Flow – a branching strategy

Version control is propably a known concept to almost every programmer. However, it is not that obvious how to handle or keep track of your changes. There are some pragmatic way like just tracking your changes and pushing them to your repo. I guess, there are some valid cases where it has some valid points, but there will be a point where that approach will be not enough anymore.

At some point I came across a blog-post about git-flow – I think a colleague gave me a hint – published in 2010! It describes a git workflow design workflow which was easy to follow and makes sense for the current projects I am working on. I’m gonna make a brief summary about the two tasks which I am using most often. There is also a cheatsheet based on that article, which summarizes all the git-flow operations.

Here are some helpful links to get into git-flow:

Btw, I am using  the command-line tool which is described in the git-flow-cheatsheet link for my operations. It’s really helpful and also has nice hint’s what comes next or should happen.

 

master and develop branch

What you should know is that git flow follows the concept of 2 “main”-branches. The master and develop branch. The master-branch represents the latest released version of your project which is also the same as on the production environment.

The develop-branch is the latest version with the newest features, which is not released yet – like the upcoming release of your project.

 

git flow feature

Use the feature if you start working on new features and change-requests. Simply use the command:

git flow feature start <Feature-Name>

That will create a new feature-branch based on the current develop-branch. By default it is only on your local machine. There is an command available which can publish it to the main repository:

git flow feature publish <Feature-Name>

If you want to pull a feature-branch from your colleague, use the following:

git flow feature track <Feature-Name>

After developing and for finishing your feature use the following command:

git flow feature finish <Feature-Name>

After that, your feature is released into the develop-branch which can be pushed to the repository so everyone can get the new feature.

 

git flow release

This command is always fun to execute, because it means that a new version is ready to be released 🙂 What it does is to make a new release-branch from the current develop branch (or other defined base). Start making a release by:

git flow release start <Release-Name>

For the release name, I usually use the actual version – like “2.0.0”. Ideally, you only alter some release-related files like the README or CHANGELOG file and release with:

git flow release finish <Release-Name>

To be ahead, I usuall add the parameter -p to the command:

git flow release finish <Release-Name> -p

What the command does:

  • merges the release-branch back into the master-branch
  • tags the release with the release-name
  • the released branch merged back into develop-branch
  • deletes the local release-branch
  • pushes develop, master and tags to origin

Btw, the release-branch can be published and tracked by your colleagues.

 

My takeaways

The git-flow strategy helps me to organize my work and also it creates some kind of standard for working together in a team. Applying the branching-strategy also helps me to scope my tasks and focus on them. A very nice plus-point is also that it plays well in CI/CD workflows – (will be one of the next topics I am going to write about).

 

So I am glad, that I discovered git-flow. It actually is not a rocket-science-thing, but it is kind of elegant in it’s simple tasks. I am taking full advantage – it helps me to work more organized.