Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: what exactly is a merge commit in git?

Tags:

git

I went through couple of blogs to understand a merge commit, but not completely clear as to what it is and what is the best practice to avoid it. And the tree diagram of the git log added further confusion to my understanding of merge commits. Help?

like image 519
Iowa Avatar asked Sep 03 '13 04:09

Iowa


1 Answers

A merge commit is just like another commit, the state of your repository at a given point in time plus the history it evolved from.

The one thing special about a merge commit is that it has at least two predecessors, therefor a plain vanilla diff doesn't make sense, you can only compare the merge with one of the predecessor, which yields the changes from the other parent(s)

To avoid merge commits, you can rebase your changes before pushing them to a remote repository.

like image 75
Jens Schauder Avatar answered Oct 06 '22 01:10

Jens Schauder