DEV Community

Cover image for Do you Git Branch in personal projects?
Madza
Madza Subscriber

Posted on

Do you Git Branch in personal projects?

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)

Collapse
 
thomasbnt profile image
Thomas Bnt

Yeah of course! Always versionning privates projects with only me to contributor.

Example :

Main branch — For production
Dev branch — For dev and test mode
Enter fullscreen mode Exit fullscreen mode

When dev is ready, I merge all on main branch 😄☕

Collapse
 
yoursunny profile image
Junxiao Shi • Edited

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 and develop. I use develop just like how I used master in the past, and push to main when I'm sure I don't need force push. main has a branch protection rule that requires CI passing and forbids force pushes.

Collapse
 
arskeliss profile image
Csokán Pál András

Brilliant, I shall follow this approach as well. >Thanks for mentioning it.

Collapse
 
ronan696 profile image
Ronan D'Souza

I too follow this approach 😎

Collapse
 
florianjisopp profile image
Florian J. Isopp

I also like this approach

Collapse
 
madza profile image
Madza

Solid approach 👍

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

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.

Collapse
 
adriens profile image
adriens

Same here, focusing on one thing at a time and realease fast each feature

Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn

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.

Collapse
 
ben profile image
Ben Halpern

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.

Collapse
 
djangotricks profile image
Aidas Bendoraitis

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.

Collapse
 
jacobmgevans profile image
Jacob Evans

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!

Collapse
 
davidmmooney profile image
davidmmooney

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.

Collapse
 
0916dhkim profile image
Danny Kim

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.

Collapse
 
polaroidkidd profile image
Daniel Einars

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 and commitLint to keep my master commits clean and generate a CHANGELOG.md

Collapse
 
jonathanyeong profile image
Jonathan Yeong • Edited

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).

Collapse
 
coopercodes profile image
🧸 🏳️‍🌈 cooper-codes 💻 🎮

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.