What to do if a bug gets into production?

beeline cloudHere I share personal experience, delve into practical problems and give detailed comments on a specific topic.

And yes, my name is still Nikolay Piskunov, I am the head of the Big Data department. Today we will talk about what to do if a bug, despite the efforts of testers, still got into production.

Hotfix comes to the rescue

Anything but that! The bug got into production!

This is the worst moment, especially when the bug report is thrown by the users of the application. In this case, you need to fix the bug as quickly as possible and deal with the consequences. Here, batman Hotfix.

In the GitFlow methodology, Hotfix is ​​a process of quickly fixing bugs in the production version of an application. It allows the development team to quickly respond to issues that require immediate attention. And most importantly, there is no need to wait for ongoing development in other branches to be completed.

The Hotfix branch is created from the master branch and then merged back into master and the develop branch. This allows you to quickly and safely fix bugs in an already released product without affecting the main code base.

A hotfix branch has several differences from other types of changes in GitFlow:

  • Created from the master branch, not from develop.

  • Merges into develop and master.

  • Takes precedence over other changes and should therefore be included in the next version of the product.

Thus, the Hotfix branch allows you to quickly and safely fix bugs in an already released product, ensuring the stability and reliability of your project.

How does Hotfix work in GitFlow?

I will highlight the key points:

  1. Creating a Hotfix branch. When a bug is fixed in a production version, a new branch is created from the current stable branch. This is usually master. The branch is usually named after the type of bug, for example, hotfix/issue-description.

  2. Bug fix. The Hotfix branch makes the changes necessary to fix the bug.

  3. Testing. After making changes, it is important to test them. It is important to check that the error has been fixed and does not cause new problems.

  4. Merge. Once successfully tested, the Hotfix branch is merged back into the main (usually master) and development (e.g. develop) branches so that the changes are available in future releases.

The benefits of using Hotfix in GitFlow are that it allows you to quickly resolve critical issues while minimizing downtime and maintaining the integrity of your production environment. Hotfixes are typically submitted by either senior developers or senior testers.

Time to correct mistakes

Let's assume that in the code that was released into production an error has crept in. According to the above algorithm, we must create a Hotfix branch from master. For simplicity, let's call it hotfix/fix_1

Let's say the developers forgot to format the username, and the testers didn't pay attention to it. As a result, the incorrect name format is returned in the response. It's a long wait for the next release, and it will take 10 minutes to fix it.

Typically in cases like this, a senior developer or team lead switches to the Hotfix branch, makes changes, commits them, and pushes them to the remote repository.

After this, two merge requests are created to ensure code consistency in different branches of the project: the first one, so that the changes get into the master branch and the fix gets into production as quickly as possible; the second one, so that the changes get into the develop branch and are available to other developers.

The only possible merge conflict here is into the develop branch. This can happen if the developers have already merged some changes into it. And this is a very real case, because development does not stand still.

After that, you can get approval from the testers for the rollout and deploy the current fix to production. Here are some Git commands that will help and diversify your work:

1. git config –global user.name “Your name” – sets the name in the system.

2. git config –global user.email “yourmail@email.com” – sets email.

These Git commands let your colleagues know who made changes to the code. Most IDEs and code editors can visualize this information nicely. For example, in VS code this information is presented like this:

3. git config –global color.ui true — enables the color theme in the terminal for Git. This allows you to use different colors to display different types of information, making the output more understandable and readable. For example, changes will be highlighted in one color, commits in another, references in a third, and so on.

4. git config –list — lists all Git settings with their current values. This can be useful for reviewing settings to make sure they are correct or to change some parameters even if you don't know their names. You can also view information about settings in the .git/config file in your project folder.

5. git init – initializes a new repository.
git clone — downloads the repository from the specified URL.

These commands help you manage project versions.

6. git status – shows the current state of the repository.

git commit -m “comment”` — makes a commit with the specified comment.
git add – adds a file to the index for subsequent commit.

With these two commands, you can capture the state of the project. Later, you can roll back to these changes or view what happened in a specific commit.

In VS code you can also view the changes and commit them:

7. git log — shows the history of changes by commits. Again, most IDEs and code editors can visualize such information beautifully. Here's what it looks like in VS code:

You can see what changes have occurred in a specific file using the command:
git log -p File Name:

9. git pull – retrieves changes from a remote repository.

10. git push – sends changes to a remote repository.

These are just the basic commands to get started with Git.

Let's sum it up

Gitflow is a simple and flexible version control process using Git that helps teams make changes to their code. The main goal is to simplify and automate the process of deciding what changes to include in the main branch and how.

Gitflow is suitable for developing popular projects based on microservice architecture. But, of course, there are also legacy projects with a huge code base, on which several hundred developers work at once. In this case, additional steps appear that are not included in the classic Gitflow.

beeline cloud — secure cloud provider. We develop cloud solutions so that you can provide your clients with the best services.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *