DEV Community

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

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 (52)

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
 
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
 
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
 
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
 
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
 
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
 
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
 
jandedobbeleer profile image
Jan De Dobbeleer • Edited

Always. I kind of developed the habit to setup CI for everything I do and doing those things “in the open”.

It forces me to think about best practices or what they would mean in that context, without pressure (although that’s not always true).

You could argue pushing to master, providing feedback at that point in time could also work, but as soon as others join in, it makes things a lot less efficient and even accessible.

I will say this though, all you need is main when it comes to pets. Treat everything else like cattle.

Collapse
 
goodevilgenius profile image
Dan Jones

I use git flow for most of my personal projects. So, I have a prod branch and a develop branch. When I've got a new version, I merge develop into prod.

I will occasionally create feature branches, if I know it might take a while to work on it. But most small stuff is put into the develop branch directly.

If anybody else were working on it, I'd be more strict and always use a feature branch.

For stuff like my blog or personal website, I only have a single branch. I don't push until I've got it ready. If I'm working on a blog post on one computer, and want to switch computers to finish it, then I'll create a branch and push it there.

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.

Collapse
 
nescalan profile image
Nelson González Escalante

Hello Madza, you are completely right. It is absolutely useful to understand and to use "Branches" in personal projects, but I think that people don't use it because they don't want to get deep in Git. 

Collapse
 
nbull92 profile image
NBull92

When I first started using github on my personal projects, I only used master. But then after getting concerned about showing it during job application processes. I made the choice to have a dev branch for development. With feature branches coming off of dev. I'd then push Dev into master, one I felt I had a new "version" that was solid to showcase.

Collapse
 
jonoyeong 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
 
_garybell profile image
Gary Bell

For most projects, yes. If it's a code/development repository I do.

I'm currently working on using GitLab to hold my blog drafts, but I only use the main branch for that so I'm not chopping and changing branches to work on different posts