Adrian World Design
  • Services
    • Website Consulting
    • Startup Consulting
    • Zend Development
  • Portfolio
    • My Framework
  • Knowledge
    • Web Standards
    • PHP bare-bones
    • Zend Framework
    • Zend Framework 2
    • Git - Github
    • Search Engine Optimization
    • Web Hosting
    • Linux
    • Microsoft Windows
    • Web Browsers
    • Mobile Devices
  • About
    • Business
    • Professionally
    • Personally
  • Contact
    • Contact Form
    • Phone
    • Email
    • Messaging

Knowledge Base Overview

What are branches

Knowledge ⇒ Git - Github ⇒ Base Concepts ⇒ What are branches
Tweet
Share on Tumblr

Created: Dec 28, 2011, 10:27:41 AM CSTLast updated: Dec 29, 2011, 10:58:38 AM CST

 This document has the answer (hopefully) about what branches are in Git. I was dumbfounded for a while and it was even tougher to find an answer but I think I get it now.

History

The answer to what branches are in Git lies in the history. At least that's where I found the answer.

I could just simply point you to the Git User's Manual where I found the answer but I don't. You should find that in your Git installation at ./doc/git/html/user-manual.html . Oh, actually I have just pointed to the manual but I will also give an excerpt here and some additional thoughts of mine.

Understanding history

Oh I love this title because I love history. We can learn so much from history and especially in IT; it's so much easier when you know how things evolved.

In this case it is a little bit different with history, though. In Git every change is (should be) logged with commits. All these commits comprise the "history in Git".

Accordingly the User's Manual has a chapter aptly named Understanding History: Commits.

What is a branch?

Within this chapter we also have a sub-chapter What is a branch? with a very short answer to what branches are. Here's the excerpt from it

When we need to be precise, we will use the word "branch" to mean a line of development, and "branch head" (or just "head") to mean a reference to the most recent commit on a branch. ... However, when no confusion will result, we often just use the term "branch" both for branches and for branch heads.

Got it? No? I didn't really at first but there is a little example just above this sub-chapter and reference in this quote.

Diagrams

It will become clearer when we look at that example which is about History diagrams.

The example looks like this

        o--o--o <-- Branch A
      /
o--o--o <-- master
      \
        o--o--o <-- Branch B

In the manual it says about diagrams "We will sometimes represent git history using diagrams ..." and this makes it somewhat clear what branches as a concept indeed are.

In this diagram each letter "o" represent a commit and we can see that branches divert—or branch out—from the master. Branch A and Branch B are different development paths or as we now have learned branches.

The idea behind this is to develop without touching the master. At least, that's how I see it.

The other idea and thing to understand about this concept is that we have to later "merge" the branch back into the master. I guess you have also seen and wondered about the merge command.

Merge branches

Since I have this final understanding about branches, merge becomes clear, too. I will end here and not dive into merge and maybe have another article about that later. When I know more about it!

blog comments powered by Disqus
Prev
Next

Powered by FeedBurner Load our "Knowledge Base" feed in your RSS feeder

Follow us on Twitter
Follow us on Facebook
Follow us on LinkedIn
Follow us on Google+

All rights reserved, Adrian World Design ©2009–2023 Powered by Wejas Framework

Jump to Top