Elektrine lite

← Feed

@isaiah@mastodon.social

2026-04-17 00:48 UTC

so… being solo for so long, i have questions about best-practice git usage. when you're working — let's say on a specific reported bug… - do you make a new branch for just this bug? or do you put a bunch of fixes in each branch? - do you keep multiple branches in different directories? or do you use git to hop between branches in one dir? - when you merge/pull the fix, do you delete the branch afterwards? or do you keep that branch going and re-merge again later?

Replies (8)

  • @cocoaphony@mastodon.social 2026-04-17 00:52

    @isaiah@mastodon.social generally a new branch per "thing to do" (bug, new feature, experiment). Worktrees let you put these in separate directories, while still letting git manage them. And I believe in short-lived branches. I do something, merge it, delete the branch. I generally even do this when I'm working on personal projects.

    Open ##1222682

  • @isaiah@mastodon.social Make a new branch for each bug. Use git to hop between branches. Delete the branch afterwards. You can probably get away with force push to rewrite a branch’s history, but as soon as you have other people, you’ll want to disable that. I use git flow, but I don’t always follow it so strictly.

    Open ##1222918

  • @isaiah@mastodon.social 2026-04-17 01:01

    last question: do you use git differently on your personal projects than on your corporate work?

    Open ##1223235

  • @MrRooni@mastodon.social 2026-04-17 03:22

    @isaiah@mastodon.social Everything in one dir, a branch for each feature or bug, merge & delete branch.

    Open ##1231312

  • @nguarracino@techhub.social 2026-04-17 02:03

    @isaiah@mastodon.social We can't push directly to main, so yes, new branch for each bug fix or feature. I rebase liberally on this branch since it's just for me. Generally try to do just one fix per branch unless there's another closely related fix in the same area. I delete the branch after merging or else they would just clutter things up over time. Usually switch between branches in the same directory, unless it's a big structural refactoring that would make switching difficult. I follow this for personal projects too, mostly because I'm so used to it I think.

    Open ##2695918

  • @arroz@mastodon.social 2026-04-17 07:31

    @isaiah@mastodon.social As always, it depends. If I’m doing something and I find a related bug I usually just sneak the fix in the same branch. I often use the main work directory for work but I usually keep one or more work trees as well (one of them with the main branch of the project, or a branch rebased to it, always ready to run to be used as reference). I never delete anything. I believe tools should handle information, you shouldn’t have to delete it for this to be manageable.

    Open ##2695920

  • @nilrog@mastodon.nu 2026-04-17 22:15

    @isaiah@mastodon.social At work I rely 💯 on local branches for whatever I do. And I push patches to gerrit from those branches. Only one checkout and I use git to switch what I am working on. Once a patch is merged in gerrit, I delete the local branch

    Open ##2695921

  • @glebd@mastodon.social 2026-04-18 01:58

    @isaiah@mastodon.social I use jujutsu on top of my git repos, it’s a game changer - imagine being able to work on top of a virtual merge of multiple branches while keeping them clean and tidy https://github.com/jj-vcs/jj

    Open ##2695922