What are branches in git?

I have several Git repositories that have one branch named "master". But what are branches and what can you do with them?

Thanks.

+4
source share
5 answers

Branches are used when you want to develop a specific function for yourself in the environment. This means that you do not mix unverified code with the trunk, usually a stable version. You branch out until you develop and test this feature, then merge the branch back into the trunk.

+2
source

Branches are usually parallel development flows that are independent of each other. Like a timeline. Here is a software project with several branches.

You may have a branch that contains all of your stable work, for example, and another that contains experimental work. You may have another intermediate branch between which is used to qualify changes from the experimental branch before moving it to a stable one. These are all branching strategies . Different teams may have different branches, etc.

Depending on your version control system, the implementation and use of branches can be significantly different. In centralized version control systems (such as SVNs), a branch is essentially a copy of the whole source code during branching (similar to cp -R in the file system). After this, development will continue on this branch, independent of the main one. So you will have something like this

 --o---0---o---o---o---- (parent branch) \ \---o---o---0--- (new branch) 

o means commit, and 0 is the branch point. The branches that you make with this system are global (each of you can see them in the project), and they are quite heavy. You can merge return the new branch back to the parent branch. This may result in merge conflicts .

With decentralized VCs (I use git as an example), branches are much lighter. They simply indicate a position in the DAG that represents the history of your project. You can force them forward by creating a new commit. In addition, the branches will be local (i.e. only you can see them if you do not decide to publish them).

However, forking and merging have some conceptual content that you cannot understand without reading documents. I would suggest that you look at the VCS documentation you are using and return to the stack overflow with specific questions if you have any.

+2
source

Here is a good article that I would like to refer to all the time: Successful Git Branching Model

This article is a practical and successful case study of a team that effectively collaborates with Git.

+1
source

Since you're new to GIT, I enthusiastically recommend reading Chapter 3 in this book:

http://progit.org/book/

@ Nufal and @ Jacob have already given a good answer, I believe. However, when it comes to the practical side of using GIT, you will always be mistaken because of the different syntax of the branches (master, source of origin, source / master, etc.

Also, I recommend reading the concepts of GIT, and not how to use it, so check out this link and you might be interested to know about the branch:

http://www.eecs.harvard.edu/~cduan/technical/git/

0
source

complementing the answers provided, there is a git webcast regarding branching and merging at http://gitcasts.com/ , or go directly to http://blip.tv/file/4094707

0
source

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


All Articles