How many types of branches exist in git?

Struggling to understand how to work with remote branches and how many types of git branches there are I somehow got lost in differing namings and git versions. Here’s a few things that happened to me, while believing there are only TWO types of git branches:

  1. I unwillingly created a non-tracking local branch (so push and pull didn’t work)
  2. (I therefore decided to abandon automatic push/pull for a while)
  3. I merged origin/master into my current branch without having fetched from origin before
  4. I merged master into my current branch without having merged origin/master into it first.

So, after having spent some time mainly at and on stackoverflow, I got to the conclusion that I can actually describe FOUR instead of the commonly described two types (local vs remote) of git branches. I decided I would try to draw my understanding of how to work with remote branches, I know it is extremely reduced, but the idea would be to point in the right direction and get an idea of the different branch levels:

Edit: New picture, incorporating dunni’s comment.
enter image description here

What do you think, how much did I get wrong? What should be added/noted?

  • How do I merge without losing commit history?
  • Determining why github says “Closed with unmerged commits”
  • ''subl' --wait' doesn't work while merging branch
  • Git: after preparing a real merge commit, how to create a simple commit?
  • Git: Determining merge changes when no conflicts
  • How do you git fetch then merge? “Error: Your local changes to the following files would be overwritten by merge”
  • Changing git conflict markers
  • Strange git merge issue
  • 2 Solutions collect form web for “How many types of branches exist in git?”

    You have one error in your picture: The branch origin/master doesn’t exist on the server, it’s called master. The branches on the server are just local branches from the servers POV.

    I also wouldn’t distinct between tracking branches and purely local branches, because the branches itself have no differences, other than the little configuration, which would simplify/enable pulling and pushing. But you can also pull to a local branch, which has no tracking configuration, you just need some additional arguments for the pull command.

    The branches on the server are not prefixed with origin. origin is YOUR name for the remote. It’s the default name for a remote but you can name it any way you like. Conceptually master on the server and your local master are the same; your machine could easily act as a server for someone else.

    Also I wouldn’t distinguish between “tracking” and “remote tracking” branches. master is the remote tracking branch for the remote’s master which you have as a copy in a remote branch named origin/master. You cannot directly manipulate remote branches; only commands that communicate with the remote such as push and fetch may perform updates.

    There is also no difference between a tracking and what you call a purely local branch. A tracking branch allows some shorthands and lets you omit the remote part in, e.g., merges and rebases. You can do anything without your local branches having to track the remote branches but it is less convenient.

    Git Baby is a git and github fan, let's start git clone.