Parent-Child Commits in Git Log
Learning to read Git log is also an essential skill. Previously, I had some confusion about parent-child relationships in commits, so here’s a summary to organize my thoughts.
If there’s no MR, commits in a single branch are actually a straight line. But because of MR, the entire commit graph becomes a tree structure.
Summary
For a commit, the commit it was based on when created (i.e., the previous commit) will be its parent commit
For a commit, if a commit is created based on it, that will be its child commit
Each commit’s
parent commit and child commit are not necessarily unique
As shown below, this merge commit will have two parents
Final Thoughts
Git looks simple, but using it well requires skill. Personally, I think the best way to learn is to think about principles during practice and summarize more.