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?
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.
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.
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.
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
.)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With