Live data from Hacker News

My unorthodox, branchless Git workflow

drewdevault.com

31–40 of 48 posts

Re: My unorthodox, branchless Git workflow

#31

If I read correctly, this is trunk-based development. https://trunkbaseddevelopment.com/ And this is also my experience, I absolutely hate spending time to merge things and resolve the conflicts and bugs. I think this should be the default behavior for small/medium teams. Branching should only be used when trunk-based dev is no longer possible. I really liked this article from the Our Machinery guys, who created the…

Branches are still very much a thing in trunk-based development.

Re: My unorthodox, branchless Git workflow

#32
post #25

> I’ll just apply them to master, rebase them behind my WIP work, and then use git push origin HEAD~5:refs/heads/master to send them upstream, or something to that effect. if you're going through the trouble of carefully rebasing to change the order of commits, and remembering exactly how many commits behind HEAD you should push, and remembering what state the remote is in (what is master is actually pointing at HEAD…

With you 100%. And yes, I will sue.

What will you sue?

Re: My unorthodox, branchless Git workflow

#33

I think the success of such a workflow says a lot of positive things both about drewdevault and git. With respect to git, this is yet another successful workflow conducted through git. While git may have its flaws, one cannot deny that many different workflows are enabled by it. And with respect to this particular workflow, I think it says that drewdevault makes largely self-contained commits with good commit message…

>While git may have its flaws, one cannot deny that many different workflows are enabled by it.

Eh. I can use an iPad as a cutting board, but I'm not going to put that down as one of the iPad's achievements.

Re: My unorthodox, branchless Git workflow

#34
This is a very eclectic workflow that might work if you have very good mental organization. For most people this sounds a recipe for disaster. A good way to lose work and get confused about the scope of individual features.

I tend to think of git as tool to aid organization and not an opportunity to flex my prowess at mental gymnastics. Crazy, I know.

Re: My unorthodox, branchless Git workflow

#35

Earlier quoted context omitted.

git checkout -b new_feature_branch is an onerous workflow?

Switching branches does get a bit annoying if you happen to work in multiple branches simultaneously and have to switch halfway through a task, or there's a lot of differences; however, that is also a matter of organization. It's happened to me though; one scenario is that you created a couple of merge requests for the same repo over the course of a day, and the next day feedback from code review or testing comes in.…

git worktree[0] can help with working on multiple branches at once, especially if your workflow involves having a bunch of uncomitted changes. You could also stash them, but if there are more complex things like submodules, ignored build artifacts and so on you don't want to mess with then worktrees are a good alternative.

[0] https://git-scm.com/docs/git-worktree

Re: My unorthodox, branchless Git workflow

#37
post #21

Isn't it incredibly annoying to edit a git change that isn't at the branch (HEAD) tip? Our workplace uses gerrit, and while it sort of supports this workflow I personally use a lot of short-lived branches, one for each gerrit review, simply in order to get at them easily to make changes.

It's a lot easier with git commit --fixup:

https://blog.sebastian-daschner.com/entries/git-commit-fixup...

Re: My unorthodox, branchless Git workflow

#38

Earlier quoted context omitted.

git checkout -b new_feature_branch is an onerous workflow?

Switching branches does get a bit annoying if you happen to work in multiple branches simultaneously and have to switch halfway through a task, or there's a lot of differences; however, that is also a matter of organization. It's happened to me though; one scenario is that you created a couple of merge requests for the same repo over the course of a day, and the next day feedback from code review or testing comes in.…

Git checkout understands "hyphen expansion" for your previous branch (a la `cd -` to switch to your previous working directory), so switching between two branches is as easy as `git checkout -` or even `git co -` if you have an alias.

Re: My unorthodox, branchless Git workflow

#39

Earlier quoted context omitted.

git checkout -b new_feature_branch is an onerous workflow?

Switching branches does get a bit annoying if you happen to work in multiple branches simultaneously and have to switch halfway through a task, or there's a lot of differences; however, that is also a matter of organization. It's happened to me though; one scenario is that you created a couple of merge requests for the same repo over the course of a day, and the next day feedback from code review or testing comes in.…

> Switching branches does get a bit annoying if you happen to work in multiple branches simultaneously and have to switch halfway through a task, or there's a lot of differences

Sure, but its not like the different changes just don’t exist if you use only master, branches are a way of managing them separately and only merging when you are ready, if you don’t use branches, you have to have some other way to manage this. If you don’t, and its not a problem, then you could also just not work on three branches at once.

Re: My unorthodox, branchless Git workflow

#40
This workflow doesn’t seem weird or unorthodox to me, it just seems like a solo contributor workflow. There aren’t as many reasons to use branches when you aren’t working with other people in those branches. It seems fine to skip some of the overhead when you’re by yourself. The implicit suggestion that everyone else is always using branches does seem a bit strange, if that’s the implication. I use branches when I need them, but I don’t always use them, and usually on small teams we adopt a policy of checking self-contained single-commit features into master, and using branches for multi-person, multi-commit, and multi-day features.

    No time spent creating new branches for new features.
    No time spent switching between branches to address feedback.
    All of my features are guaranteed to be mutually applicable to master, saving me time addressing conflicts.
    Any conflicts with upstream are addressed in all of my workstreams at once, without switching between branches or allowing any branch to get stale.
To be honest all 4 of these are unconvincing. Creating branches and switching branches is a non-problem, these operations are faster than committing.

To the third and fourths points - that all “streams” resolve at the same time, that’s an okay point, but isn’t normally a problem in practice with branches. If you’re working on multiple branches than conflict with an incoming commit, it means you’ve touched the same code in multiple branches, and also someone else has too. It tends to indicate bad planning or bad communication or both. And it just doesn’t happen very often.

Here are a few reasons to use branching anyway when you’re alone:

- To do an experiment multiple ways on the same code.

- To avoid use of git stash. Branching is safer and adds no extra difficulty. Stash doesn’t have as good of a safety net (it’s in the manual).

- To write & test your feature without your other in-progress features getting in the way.

Post reply on HN