Most devs are aware, that Git Branches are awesome for developing new features collaboratively in complex apps. For personal projects, I've seen most devs pushing everything to master, tho.
Is this because devs being lazy and lack proper project organization or do you also think branching in personal projects is unnecessary?
Even if you work alone, I still see them as useful, especially if you develop new features and have a master branch in production.
Top comments (51)
Yeah of course! Always versionning privates projects with only me to contributor.
Example :
When dev is ready, I merge all on main branch ๐โ
I used to have
master
only. If CI fails or I find a typo, I'll force push. I keep getting complaints regarding the force pushes.Now I have
main
anddevelop
. I usedevelop
just like how I usedmaster
in the past, and push tomain
when I'm sure I don't need force push.main
has a branch protection rule that requires CI passing and forbids force pushes.Brilliant, I shall follow this approach as well. >Thanks for mentioning it.
I too follow this approach ๐
I also like this approach
Solid approach ๐
Not really. I tend to focus on one thing at a time so there's no point in using feature-branches, as I'd only ever have one of them at a time anyway.
I also don't see much of a point in separating dev and stable branches since that's what tags are for and in personal projects that's more than enough.
Same here, focusing on one thing at a time and realease fast each feature
I try to make a point to do so, but am not exactly good at remembering.
The main advantage here in my opinion is not so much having a stable production copy (thatโs what releases are for) but that it lets you quickly jump back to the main branch to fix a bug independent of whatever features you happen to be working on.
Put differently, Iโm a strong believer that new features should not block bug fixes that are not inherently dependent on that new feature, and doing feature development in branches makes it easier to decouple bug fixes from feature development without having to push incomplete code to your main branch.
I'm not the world's most disciplined brancher by nature, but even I use branching on personal projects.
I took a bit of CS and am otherwise self-taught, but I'm pretty sure git was never something I took any courses in, so I mostly stumbled through learning myselfโ and when I first got started with git I could find myself just developing on the one main branch.... But I have long-since cut that habit.
If a feature or fix takes a few hours to develop, I push to the main branch. If it's a feature that will take several days to complete, I create a new branch.
This way, I can ensure, that I can do any urgent bug or security fixes to the main branch whenever necessary. And without pushing unfinished work to production.
I don't do a lot of "best practices" in early projects.
Once all the foundation is in place, I try to use as many Git best practices as I can so that I don't reinforce bad habits. Also if the project ever gets other people contributing I don't want to be a hypocrite!
I use a branch to do the work and then I send myself a PR to merge to main. This forces me into a context shift from "developer" to "reviewer". There's a lot of things my eyes will just drift past in my editor that I will flag when I'm explicitly doing quality control.
I also do this. One main branch and thousands of short-lived feature branches (e.g.
enhance/add-profile-component
) which get closed immediately after PR.yes, all the time. I use my personal website as a type of playground so I try different things. Some of them I merge, others I drop again. I also use
standard-version
andcommitLint
to keep my master commits clean and generate aCHANGELOG.md
I do! My workflow on personal projects is very different from work. In that, I find myself making commits to the main branch way more often.
However, if I want to POC something or start building a feature that won't be finished in a single session. I'll use a branch. It's easier to rollback if things break. And you can push code to your repository without triggering a build on your main branch (assuming you have CI/CD setup).
I never used to, basically only worked on smaller solo personal projects and didnโt see the need.
I do now, as my projects are getting bigger and often have some kind of continuous integration on Main branch.
Personally I donโt think itโs needed for smaller solo projects for anything other than to get comfortable with using git processes, but for that alone it is worth it.