How many branch types are there in git?

Trying to understand how to work with remote branches and how many types of git branches I somehow got lost in different names and versions of git. Here are a few things that happened to me, believing that there are only two types of git branches:

  • I reluctantly created a non-tracking local branch (so push and pull do not work)
  • (so I decided to refuse automatic pushing / turning off for a while)
  • I merged origin / master into my current branch without fetching from the source earlier
  • I merged the masters into my current branch without first combining the original / master.

So, having spent some time mainly on http://git-scm.com/book and on stackoverflow, I came to the conclusion that I can actually describe FOUR instead of the usually described two types (local and remote) of git branches. I decided that I would try to understand how to work with remote branches, I know that it is extremely short, but the idea should be in the right direction and get an idea of ​​the different levels of branches:

Edit: New image including dunni comment. enter image description here

How wrong do you think? What should be added / noted?

+5
source share
2 answers

You have one error in your image: the beginning / mastery of the branch does not exist on the server, it is called master. Server branches are only local branches from POV servers.

I would also not be distinguishable between tracking branches and purely local branches, because the branches themselves have no differences other than a small configuration, which will simplify / allow stretching and clicking. But you can also go to a local branch that does not have a tracking configuration, you just need additional arguments for the pull command.

+3
source

In branches on the server there is no prefix origin . origin - YOUR name for the remote. This is the default name for the remote, but you can name it in any way. Conceptually, the master on the server and your local master match; your machine can easily act as a server for someone else.

Also, I would not distinguish between the branches "tracking" and "remote tracking". master is the remote tracking branch for the remote master , which you have as a copy in the remote branch named origin/master . You cannot directly manipulate remote branches; only commands that communicate with the remote, such as push and fetch , can perform updates.

There is also no difference between tracking and what you call a purely local branch. The tracking branch allows for some abbreviations and allows you to omit the remote part, for example, merges and reinstallations. You can do anything if your local branches do not need to track remote branches, but this is less convenient.

+2
source

Source: https://habr.com/ru/post/1202335/


All Articles