Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limit on number of git branches

I am musing about building a big system on top of git for various reasons but mainly convenience.

But as part of the implementation I would end up making millions of branches and branching and merging between them. Can git actually scale this way? I always hear "Branches are free" but I have to wonder if this is really true x1,000,000? Can git actually create a theoretical unlimited number of branches?

like image 371
user1778366 Avatar asked Oct 26 '12 22:10

user1778366


People also ask

Is there a limit to the number of branches in git?

Yes, branches are free. Branching and merging is very easy. The scalability issues mentioned before comes only when synchronizing a vast amount of branches through the network (git fetch, git pull, git push). Locally you shouldn't have any problem.

How many branches can a repository have?

A branch is essentially is a unique set of code changes with a unique name. Each repository can have one or more branches.

How many branches should a project have?

Most projects have a minimum of two branches, master and develop .

Can I have multiple branches in git?

So you can work on two branches simultaneously. One small catch is that you can't have the same branches checked out in different worktrees. So if you have checked out one branch in one worktree, then the same branch can't be checked out in another different worktree. Another catch is worktrees sync up with each other.


2 Answers

Yes, branches are free. Branching and merging is very easy.

The scalability issues mentioned before comes only when synchronizing a vast amount of branches through the network (git fetch, git pull, git push). Locally you shouldn't have any problem.

like image 65
FelipeC Avatar answered Sep 19 '22 14:09

FelipeC


There was a thread about scalability problems in this area on the git mailing list last year, as I recall there were some improvements made but I don't recall off hand what the performance was like with the changes that got incorporated into newer versions as a result.

Here's a link to an archive of that thread:

http://git.661346.n2.nabble.com/Git-is-not-scalable-with-too-many-refs-td6456443.html

like image 38
qqx Avatar answered Sep 20 '22 14:09

qqx