Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 http://git-scm.com/book 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?

like image 607
virt Avatar asked Sep 11 '14 11:09

virt


People also ask

How many types of branches are there in Git?

The two primary branches in Git flow are main and develop. There are three types of supporting branches with different intended purposes: feature, release, and hotfix.

What are the main branches of Git?

The master branch is a default branch in Git. It is instantiated when first commit made on the project. When you make the first commit, you're given a master branch to the starting commit point. When you start making a commit, then master branch pointer automatically moves forward.

Which kind of branches can contain a Git repository?

No, the main branch can be any branch you want. By default, when you create a repository, the main branch is named the master branch. It is the base branch or the default branch. You can go through How to set up default branches in Git to know more.


1 Answers

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.

like image 143
dunni Avatar answered Sep 28 '22 00:09

dunni