Live data from Hacker News

Minimum Viable Git for Trunk-Based Development

blog.trunk.io

21–30 of 45 posts

Re: Minimum Viable Git for Trunk-Based Development

#21

I finally understand why some people are so against rebase. They're doing it wrong. I've always heard people talk about how it doesn't scale, but I use rebase like 99% of the time, and have worked on projects with hundreds of ICs. This is the first time I've seen someone explain it in a way where I get it. NO I'M NOT FORCE PUSHING TO MAIN YOU SILLY NILLY! Turns out I'm "squash rebasing." I guess I didn't know I need…

Slightly off topic

> get yelled at about --set-upstream, and copy/paste that command :-)

But you might like this https://git-scm.com/docs/git-config#Documentation/git-config...

Re: Minimum Viable Git for Trunk-Based Development

#22
post #13
post #7

> git add -A . > Add everything I’m working on (new and edited files). Bad idea. Extraneous cruft that isn't caught by .gitignore will leak into the repo. Always run git diff and git status first to see what you are about to add.

combined with the authors disdain of commit messages or documentation I can't figure out where they've chosen to document why changes are made.

commit messages != documentation

Re: Minimum Viable Git for Trunk-Based Development

#23
post #21

I finally understand why some people are so against rebase. They're doing it wrong. I've always heard people talk about how it doesn't scale, but I use rebase like 99% of the time, and have worked on projects with hundreds of ICs. This is the first time I've seen someone explain it in a way where I get it. NO I'M NOT FORCE PUSHING TO MAIN YOU SILLY NILLY! Turns out I'm "squash rebasing." I guess I didn't know I need…

Slightly off topic > get yelled at about --set-upstream, and copy/paste that command :-) But you might like this https://git-scm.com/docs/git-config#Documentation/git-config...

I just added an alias

  alias gpush='git push --set-upstream origin $( git branch --show-current )'

Re: Minimum Viable Git for Trunk-Based Development

#24
> you need to re-clone from scratch — even if you did nothing wrong.

I don't think you will need to reclone if did nothing wrong. You can always use `git reset --hard origin/...`, and if that does not work the you definitely did something wrong.

> But in Linus’s own words, Git is “the information manager from hell.”

That git is not the same git we have today, and it was handed over to another person quite early in the development. Although I agree that git ux is sometimes confusing.

> Limit your Git actions ... for peak Git efficiency

I pretty much disagree, if I can give my two cents, read the manual. Git have some really handy tooling that can help with non-git issue (e.g.: `git bisect`). Limiting your knowledge brings no benefit.

I like some point of the text, but overall I don't like the premise. it exaggerate a lot a problem to prove a point.

Re: Minimum Viable Git for Trunk-Based Development

#25
Without rebasing, tools for managing PRs might show the merged mainline commits in the PR.

Some times they are described as such “merged master into feature” and can be avoided if you review the PR per commit. But more often I want to review the PR as a whole, and then the tool fails to show a good diff of what’s actually developed in the PR. This to me is a much larger problem than the log pollution, which can be solved by squashing.

Other than that (missing the bigger reason for rebase and focusing on a lesser argument in my opinion) I quite agree with the article.

Re: Minimum Viable Git for Trunk-Based Development

#26

I finally understand why some people are so against rebase. They're doing it wrong. I've always heard people talk about how it doesn't scale, but I use rebase like 99% of the time, and have worked on projects with hundreds of ICs. This is the first time I've seen someone explain it in a way where I get it. NO I'M NOT FORCE PUSHING TO MAIN YOU SILLY NILLY! Turns out I'm "squash rebasing." I guess I didn't know I need…

Many times have I seen a green developer throw up their hands at a rebase attempt, after which we learn they were doing this:

    git checkout master; git pull

    git checkout -b fb

    git commit

    git commit

    # new changes arrive on master branch
    
    git checkout master; git pull; 

    git checkout fb; git merge master

    git commit

    # "went to the git brownbag and heard about rebase for the first time, 

    # missing that part up front about not intermingling merges with rebases 

    # and not having a good mental model of git

    git rebase master

    # WTF conflict everywhere! rebase sucks

Re: Minimum Viable Git for Trunk-Based Development

#27

Earlier quoted context omitted.

I hear you. But nothing goes directly into main. The working branch is not sacrosanct you know what I mean? I'd rather clean up anything that leaks in before merging and a good .gitignore can protect against most noise.

Sure but it goes in the repo. Forgot to add .env to the .gitignore? You probably just committed a secret. Sure you can force push to get rid of it but if you're using Github it's still saved so it needs to be rotated now.

What’s “the repo” here? What I commit goes into my copy of the repo. Only what I push goes into any repo anyone else sees. Before pushing I always go through what’s in the branch and clean up/rebase etc. Sure it’s easier to accidentally push a file you shouldn’t have if you have added it locally but committing alone doesn’t necessarily mean you need to rotate a secret.

Re: Minimum Viable Git for Trunk-Based Development

#28
Clicking through a self-link in the article https://blog.trunk.io/git-commit-messages-are-useless-c2f3c4... we read:

> This isn’t grade school, you don’t have to show your work As you become an efficient engineer, the path you took to get to the final state of a pull request becomes far less important — and is academically interesting at best. You shouldn’t have to show your work like you did in school. Land the feature or bug and move on to the next one. The code speaks for itself (alongside some judiciously placed comments).

> Having granular annotations of all your work is unnecessary, ...

This premise underlies the particular workflow that the posted article assumes, and all the described command+option incantations are directed to it.

But there is another, very different git workflow used by a project we've all heard of, and that is the Linux kernel core code. The trunk.io workflow is unsuitable for Linux due to different requirements. Some of which being:

1. Commitment to support for indefinite future.

2. Large, complex feature PRs.

3. Human review of PRs, by maintainers fully empowered to reject.

4. A low-level programming language, in which subtle bugs are easily introduced.

Also different luxuries:

1. Willingness to put off merge of a "hot" new feature indefinitely.

So, kernel PRs are structured as a linear series of numbered patches meeting the requirement that each step along the way compile cleanly. This is primarily to ease the task of the maintainer responsible for the subsystem involved, and who will have deal with the fallout of bugs introduced by the PR. Example:

https://lore.kernel.org/rcu/

Credential: I have written code for the Linux kernel core, and it was merged, and it was buggy.

Re: Minimum Viable Git for Trunk-Based Development

#29
post #7

> git add -A . > Add everything I’m working on (new and edited files). Bad idea. Extraneous cruft that isn't caught by .gitignore will leak into the repo. Always run git diff and git status first to see what you are about to add.

I hear you. But nothing goes directly into main. The working branch is not sacrosanct you know what I mean? I'd rather clean up anything that leaks in before merging and a good .gitignore can protect against most noise.

> But nothing goes directly into main.

That's not a reasonable argument. The problem is pushing confidential info into a repository. It matters nothing what the branch you push it is called.

Re: Minimum Viable Git for Trunk-Based Development

#30

I finally understand why some people are so against rebase. They're doing it wrong. I've always heard people talk about how it doesn't scale, but I use rebase like 99% of the time, and have worked on projects with hundreds of ICs. This is the first time I've seen someone explain it in a way where I get it. NO I'M NOT FORCE PUSHING TO MAIN YOU SILLY NILLY! Turns out I'm "squash rebasing." I guess I didn't know I need…

Why not just ‘git merge main’ instead of ‘git rebase main’?
Post reply on HN