Why do we need dev branch?

I was using master as a dev branch and I tought that dev branch is not necessary. I changed my mind.

I did't need dev branch. Because, my projects didn't need urgent bugfix or hotfix releases. But not getting in any trouble without dev branch doesn't mean everything is always gonna be okay.

Case

Think about that case; You are on version 0.2.0 and you started to work for version 0.3.0 in master as development branch. On testing or production environment some urgent bugs are rised. This bugs should be fixed as soon as possible. What is gonna happen? Are you going to work for them in master too? Or are you going to work for them in another branch named like bugfix-0.2.1 or hotfix-0.2.1 and then merge it into master? But there were some new features from 0.3.0 which shouldn't be released yet. We can't do it by using master branch as our development branch. Theese kind of releases are called bugfix or hotfix versions.

Solution

Here is the way of doing it as ideal. Having always dev branch besides master and handling all developments in it solves the problem. Always keep master on last version and do development in dev branch. Lets consider the case one more time for the solution. You are on version 0.2.0 and you started to work for version 0.3.0 in dev branch. On testing or production environment some urgent bugs are rised. This bugs should be fixed as soon as possible. You create bugfix-0.2.1 or hotfix-0.2.1 branch, do your job and merge it into master. You tag master with 0.2.1 . All new features from 0.3.0 are in dev branch after all. So you are not going to get in any trouble. After you are done with 0.3.0, you merge it into master and tag master with 0.3.0 and have clean history.