Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git branches on a solo project

Tags:

git

Is there any reason to create branches for features in a solo git repo? When I merge them back into master, they fast-forward and there is no real evidence that I even branched in the first place. Should I even bother?

like image 674
Eric B Avatar asked Jun 07 '13 18:06

Eric B


People also ask

Can I have multiple branches in Git?

Git offers a feature referred to as a worktree, and what it does is allow you to have multiple branches running at the same time. It does this by creating a new directory for you with a copy of your git repository that is synced between the two directories where they are stored.

How many branches can you have for a Git repository?

There is no hard limit on the number of branches, tags, remote-tracking names, and other references. (All of Git's name-to-hash-ID map entries are refs or references: branch names are just refs whose full name starts with refs/heads/ ). These are not always stored in separate files.

What is the most popular branching strategy in Git?

Git Flow is by far the most popular Git branching strategy out there, and it's one of the oldest still in use today. It centers around having two branches: "main" and "develop." The principle behind this strategy is that all the code being developed is merged to the develop branch.


2 Answers

Branches can be really useful, even on a solo project. They allow you to develop new features in isolation (if need be) while easily allowing you to throw out work, and/or keep it separated from mainline development (so you can start new features from a clean, stable portion of your codebase).

(You can also prevent fast-forward merges by passing the --no-ff flag to git merge.)

like image 174
mipadi Avatar answered Sep 18 '22 08:09

mipadi


You can merge without fast-forwarding, check e.g. What is the difference between `git merge` and `git merge --no-ff`?

And answering your question, I use branches in my solo projects e.g. to isolate experimental features. I might want to switch from Bootstrap to Zurb or from Knockout to Angular and a separate branch gives me a peace of mind.

like image 27
Tomasz Zieliński Avatar answered Sep 19 '22 08:09

Tomasz Zieliński