Is it better to use a separate commit message to merge git?

I come from an SVN background, so I'm not sure what a typical git workflow looks like. When you merge into SVN, you provide a commit message describing the merge. This is necessary because SVN merge tracking has historically been poor.

I noticed that the default behavior of git is to automatically commit the results of a merge if it succeeds. This means that merges are usually not displayed in the log, therefore everything in the history looks as if it was developed in one branch. Is it advisable to show cream as extra commits? I can think of several reasons why and why not, but I would like to get some data from other users.

+4
source share
2 answers

If you do not provide the --no-merges for git log , it usually displays merges, which give a brief automatic description of the commit.

This is usually normal, since git records the origin of the commit, and interesting merge functions are its composite branches.

Try using git log --graph --oneline or use the graphical history viewer, and you can (must!) git log --graph --oneline sure that the way git records a merge is much more important and useful than a message with a merge commit with a long branch .

Mergers really need a detailed message about the completion, if the decision was something magical. Since this means manual intervention, it is easy to add at this point.

+5
source

I think you are mistaken in two situations (or I don’t understand what you are asking).

  • If you combine the side branch, which is a direct child of the branch you are currently on, this leads to the so-called fast-forward . Regular git did not create a merge compilation, but simply pointed to a branch, but you can prevent it with the --no-ff option.

    By default, such meaningless mergers should be avoided because it works better in truly distributed development.

  • If the branch you are in and the branch you are merging really diverge, that is, there are commits on each branch that are not in the other branch, git will merge, and if it is possible to merge without conflict, it will automatically create a merge commit . Such a merge commit will have an automatic commit message with the variable merge.log config (formerly merge.summary ). You can prevent this automatic commit with the --no-commit option.

    Of course, git log will show merge commands unless you use git log --no-merges.

I hope this explanation helps a bit.

+7
source

All Articles