Parent-Child Commits in Git Log

This article introduces parent-child commits in Git log, including their advantages, implementation details, and related resources. These steps can help improve understanding of parent-child commits in Git log.

Oct 29, 2020 · 1 min read · 142 Words · -Views -Comments · Programming
Git 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

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.

Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover