Git performance with Big Commits vs tiny commits

All coding standards and good practices speak aside how Git itself technically deals with huge commits against small commits. For example, Git is smarter if the branch merges (for example, fewer conflicts) with any of the cases, does garbage collection make it more efficient or something like that? Or is there any difference?

To be clear, I mean a scenario where the code changes from A to B, and the “huge commit” just changes the code from A to B, and the “small commit” has many intermediate commits (say, for every small change to a function), but ends up with the same B.

+6
source share
1 answer

Many small commits will use a little more space, but the difference is probably not worth the price of a lost story.

The effect on the package file itself will depend on how many changes were subsequently changed. For example, if a later commit affects lines that were affected by an earlier commit, the intermediate state of these lines will not be visible in the history with one large commit, and thus there will be no object in the batch file.

I can’t imagine that the number of commits on a branch would reduce or increase the complexity of a merge; but I cannot speak with this authority, since I have not studied how a typical merge is made recursive. I understand that it is equivalent to diff3 from the last point at which they were merged (or split). In this case, one large fixation will not be more or less effective than many small fixations.

There is another aspect that should be considered with time. If you work on a branch and regularly merge the upstream branch between your own commits, then many small commits will cause less conflict because you will maintain better parity with the upstream branch and therefore deviate less from it. This will certainly cause fewer problems when the time comes for a merger.

Garbage collection will be largely unaffected, as in both cases there are no dangling commits or free objects inherent in any method.

In general, batch files are usually quite effective when working with text, so the advantage of being able to view a complete and genuine story often outweighs the cost of the extra space that is required.

+4
source

Source: https://habr.com/ru/post/914866/


All Articles