S
S
sprashivatel2020-03-08 13:49:46
git
sprashivatel, 2020-03-08 13:49:46

What is the meaning of commits in the same branch?

I tried to use the git, but I didn’t really get it: well, I created a new branch (version) from the master and started editing, making some incomprehensible commits.

Well, if it’s clear with the branches: you switched to it and you are in the state in which this particular branch (version) is, then I didn’t understand with commits how to roll back to, for example, some state:

Test branch commits:
1. added controller Test
2. added controller method Test::test
3. added view /view/Test/test.php
4. added model Test

how do I go from position 4 to position 1 in the branch and so that there are no positions 2-4 in the project so that these files were not

If in any way, then why commits?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor Bomberow, 2020-03-08
@sprashivatel

If the development is carried out by one developer, then you are free to use any workflow that is convenient for you.
But usually such repositories, on average for the hospital, look like this:
Master branch: each commit means a new version that builds without errors.
The devel: branch may be missing, but it is usually used as the current one, which, when there is no mood / time to finish work on new functionality.
All sorts of different branches with different names: they usually mean working on some kind of complex functionality, for example, if for a toy software renderer repository you need to remove the concept of "canvas" and transfer the functionality between two new entities "camera" and "scene"; depending on the quality of observance of OOP in the current codebase, this task can stretch for a long time. But, nevertheless, it will not interfere with adding new clipping algorithms from time to time, each in its own branch, new rasterization algorithms, or adding patches, refactoring the working version.
Of course, doing many branches is not worth it, because it is desirable to do a rebase for each branch so that they look at the latest develop commit, and it is desirable that develop also always builds.
Thus, a commit for each of such a branch means a checkpoint, or a click to save the file, by analogy with writing a large text document. In any case, it may not be worth doing for each addition of a method, but it is worth doing exactly for what you yourself consider an atomic change to your codebase. Usually, they are more related to making changes to the domain model, the steps of these changes.
Just keep in mind that when moving to collaborative development, you will have to reconsider your concept of atomicity.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question