DEV Community

Cover image for Do you merge branches locally or create pull requests for personal projects?
Ben Lovy
Ben Lovy

Posted on

Do you merge branches locally or create pull requests for personal projects?

I'm not sure if this is #help. Is there a correct, universally accepted better practice? In that case, yes, help me by telling me what I should be doing.

I kind of do both. If it's a relatively small change, I'll just (squash and) merge my local work branch into my local master branch and then push to origin/master, cleaning up my local branch locally. Nice and clean.

For larger changes, or changes that take me more than a session to implement, I push to origin/<branch-name> and then open a pull request. I then use GitHub to squash, merge, and delete the work branch.

This feels a little cleaner and more organized, but it also feels a little silly to "review" and "accept" changes where I was the only person involved.

obama meme

Ben accepting his own PR, 2020

If there isn't a "one true way", please #discuss your own personal preference! Mods, feel free to de-#help me.

Photo by pine watt on Unsplash

Latest comments (41)

Collapse
 
bhupesh profile image
Bhupesh Varshney 👾

I do this a lot.
Additionally I have setup a ton of type-checker, Dynamic Testing Tools
This helps me judge my code

Collapse
 
cyberhck profile image
Nishchal Gautam

I protect my master branch, unless my ci says that changes are alright, they don't go to master

Collapse
 
mattmcadams profile image
Matthew McAdams

I agree it feels kind of silly at times but for me it’s part of learning and building a habit of using git in a “real” workflow. I also do my best to use GitHub issues on public personal projects, just so there is a public record of todo items / bugs on the off chance someone wants to use / fork the project or contribute.

I’m really obsessive over organization though so it might just be me.

Collapse
 
miteshkamat27 profile image
Mitesh Kamat

Well, I have made it a habit that even if I work on a small change I should create a pull request.It could sound silly to create a pull request where you are the only reviewer but it helps in future. You get another chance to review your code and refactor it.

Collapse
 
gablaroche profile image
Gabriel Laroche

I usually just close my eyes and push to origin/master. But seriously though, if it's a big change might make a pr.

Collapse
 
ayozebarrera profile image
Ayoze Barrera 🇮🇨

PR linked with a issue describing the change ♥️

Collapse
 
deciduously profile image
Ben Lovy

Tools only work if you use 'em!

Collapse
 
deciduously profile image
Ben Lovy

gasp

Collapse
 
patarapolw profile image
Pacharapol Withayasakpunt

If my project get stable enough, I work outside master to prevent breaking the master branch itself; then merge online; because web UI tools do help.

Collapse
 
ogrotten profile image
ogrotten

I use local branching very liberally. Branch, work, branch a branch, debug, merge, finish feature, merge to master, push to remote.

Most of my personal projects only have master pushed to it. Only if I'm "done for now" and haven't completed somethign will I publish the branch.

For personal projects, it's pretty rare.

Collapse
 
jhechtf profile image
Jim Burbridge

I tend to make the changes in a branch and push them up to Gitlab. I tend to have some variety of testing that goes on before I can merge the results (Linting, Unit, etc), so even though I'm paranoid and will run those locally it's nice to have a record that 'when I pushed the merge request up the tests ran fine. Not sure why they messed up now.' I do it even for my personal site most time (though i will occasionally start working on something, get two commits in and realize I forgot to make a new branch).