By itself, branches are not versioning tools. I’ll come back to that later.
Within a development process, you can use branches to isolate development. This allows you to change a code base without necessarily affecting the entire stable part of the code. I particularly use the workflow gitflow.
In addition to separate feature development, it also allows you to have a stable branch (master
) and an unstable (develop
). What do I mean that branches are stable and unstable? Well, any correction will only make the system more stable (in theory), so corrections in that direction would not increase software instability. Thus, a production code after undergoing a correction, the new code will also be ready to go to production.
On the other hand, a functionality or system rearquiteture can bring great instabilities in the system. Applying this code change has the highest risk of introducing bugs. So if a production code undergoes this kind of change, it will no longer be ready to go into production.
See more on the link I posted on the gitflow.
Branches and versions
In several projects you will find that the repository includes branches such as v4.5-stable
, v4.6-stable
and v5-unstable
.
But what is the function of these branches? Well, they have no versioning function, but provide stability for each version. This depends on the life cycle of each release.
Disregarding patches
with fixes that need to be delivered in hot, I have only worked on projects whose life cycle is weeks, and the new version totally supplants the old and is no longer offered maintenance the previous version. So I don’t have much experience in this kind of development with long life cycles with overlapping stable versions, but I can speculate.
This separation of maintenance branches allows the correction to be made where the problem was detected and then propagated to the other versions "more in the future", all without forcing the client to update the version he is using. This also prevents new features (which bring instability) from being inserted into older versions but still supporting them.
Why not use branches to see?
Basically because branches are changeable, they were made to be changed. Versions, no. Version v4.5.17
you want it to always be the same version v4.5.17
, No? If you put as branch v4.5.17
, someone can commit and change the version code, without changing the version identifier string.
In git, you get some of that immutability by using tags. In thesis, tags are points in the code history. They are not changing heads, they can evolve. They are just "pointers" to a certain point in the code.
Answering specific points
Because creating branches is important in software versioning, rather than just using "master" (in large, medium, small or even personal applications)?
Separate branches help in the stability of the software. They also don’t carry much weight of use, concept, time or tools.
Anyway, if you work with git hosted on some server, you is already working with branches. At the very least, the master
location and the remote.
What advantages do I have in using them?
Stability and isolation.
A versioning without them can entail some "evil"?
If you’re too disciplined, you wouldn’t need to development. But using branches in your workflow helps against eventual human failures.
Could a lot of branches become a problem? If so, how much would that be?
Yes, they can generate negative effects. For example, client software can take a long time to display branches. Or make it difficult to find a specific branch. I’ve suffered it with a setup on Jenkins, but they managed to get around where I work by changing from one select box
simple for something more interactive with filters.
Another problem you can cause is with co-workers. One fine day an old employee (who worked before git and if he depended on it would continue with CVS) complained that there were more than 10 branches in the repository...
Versioning is usually done in tags, which would be an "immutable state in history". Which versioning system do you use?
– Jefferson Quesado
@Jeffersonquesado GIT, in case would version control? Help me kkkk .-.
– Vinícius Lima