this post was submitted on 28 Aug 2024
518 points (96.9% liked)

Programmer Humor

32016 readers
446 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] dohpaz42@lemmy.world 53 points 2 weeks ago (2 children)

I know this is a joke, but those errors/warnings/messages screenshot is not from git. That looks more like results from a compiler of some sort.

[–] dfyx@lemmy.helios42.de 37 points 2 weeks ago* (last edited 2 weeks ago)

Looks exactly like Visual Studio 2022.

I guess the joke implies that automated (or incorrect manual) conflict resolution causes code that doesn't compile. But still not git's fault. They should probably have merged earlier and in rare cases where that wasn't possible, you have to bite the bullet and fix this stuff.

[–] PotatoesFall@discuss.tchncs.de 4 points 2 weeks ago (1 children)

When people do a bunch of bulk renames on every commit, then you get this kind of problem a lot. But yeah still not gits fault

[–] dohpaz42@lemmy.world 4 points 2 weeks ago (1 children)

In my experience, this amount of conflicts typically occurs because 1) most people mass commit a bunch of (mostly unrelated) changes at once, which leads to 2) inexperienced/impatient devs to clobber incoming merge conflicts without doing proper merges (mostly because they can’t make heads or tails of the diffs).

This is very easily mitigated if all developers would make small, related commits (with descriptive commit messages and not “committing changes”). This makes everybody’s life easier because 1) diffs are smaller and readable for conflicts, 2) the dev can see the progression of code through commit history, 3) broken code is more easily revertable (and traceable) if something goes wrong, and 4) it’s easier to cherry pick specific changes if the whole changes cannot be published all at once.

Also, git pull --rebase is your friend and not scary at all. It applies all incoming changes first, then applies your new commits last. 9 out of 10 times it avoids conflicts.

Lastly, use a GUI. There are plenty out there to suit your tastes, and I feel they are a safer and easier alternative than CLI. Some GUIs are very safe and even allow undo operations on most things.

[–] PotatoesFall@discuss.tchncs.de 2 points 2 weeks ago (1 children)

not scary at all

I have seen some juniors really shoot themselves in the foot with rebasing, and I've been there as well before. I agree it can be useful, but it definitely requires understanding of what is going on :P

[–] dohpaz42@lemmy.world 3 points 2 weeks ago

What I suggest is not the same as using git rebase. It’s pretty automatic and easily abortable.

[–] gerryflap@feddit.nl 43 points 2 weeks ago (2 children)

Sometimes I look at the memes around here and wonder wtf y'all are doing. Like, neither my code nor the code at the place I work at are perfect. But I don't think I've ever seen a merge do this. Maybe some of the most diverged merges temporarily had a lot of errors because of some refactoring, but then it was just a few find + replaces away from being fixed again. But those were merges where multiple teams had been working on both the original and the fork for years and even then it was usually pretty okay.

[–] Daxtron2@startrek.website 28 points 2 weeks ago (1 children)
[–] GreatRam@lemmy.world 4 points 2 weeks ago (1 children)

This is true. I got really good at fixing merge conflicts in college

[–] Daxtron2@startrek.website 3 points 2 weeks ago

You kinda have to when half of your "team" is barely even able to write code.

[–] Doxin@pawb.social 4 points 2 weeks ago

It's really easy to make a gigantic mess using git if you don't know what you're doing. As soon as you learn to keep your history mostly linear all those issues go away.

[–] cyborganism@lemmy.ca 39 points 2 weeks ago (2 children)

You need to merge more often.

Rebase. That's where the real trauma is.

[–] zalgotext@sh.itjust.works 24 points 2 weeks ago (2 children)

Neither rebasing nor merging should cause trauma if everyone on the team takes a day or two to understand git

[–] cyborganism@lemmy.ca 11 points 2 weeks ago (5 children)

I consider myself above average in terms of Git know how. But I've come across situations using rebase where you're stuck resolving the same conflicts over several commits.

I still don't understand that part quite well.

This doesn't happen when you do a normal merge though. Making it easier to manage

[–] furikuri@programming.dev 5 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

You could try making enabling git's rerere functionality, which stands for "reuse recorded resolution"

https://git-scm.com/book/en/v2/Git-Tools-Rerere

https://stackoverflow.com/a/49501436

load more comments (1 replies)
[–] sushibowl@feddit.nl 3 points 2 weeks ago (2 children)

The reason for this is that git rebase is kind of like executing a separate merge for every commit that is being reapplied. A proper merge on the other hand looks at the tips of the two branches and thus considers all the commits/changes "at once."

You can improve the situation with git rerere

[–] cyborganism@lemmy.ca 2 points 2 weeks ago

Holy shit! I never took the time to read about it rerere. But it all makes sense now.

However, it's still a lot of extra steps for what could otherwise be really simple with a regular merge.

Is there really a big advantage in using rebase vs merge other than trying to keep a single line of progress in the history? It's it really worth all the hassle? Especially if you're using a squash merge in a pull request...

load more comments (1 replies)
[–] CMahaff@lemmy.world 3 points 2 weeks ago (1 children)

Another solution to this situation is to squash your changes in place so that your branch is just 1 commit, and then do the rebase against your master branch or equivalent.

Works great if you're willing to lose the commit history on your branch, which obviously isn't always the case.

[–] cyborganism@lemmy.ca 2 points 2 weeks ago

Yeah that's what I did as a workaround. Reset (soft) to the first parent commit and do a single commit with all the changes.

[–] jjjalljs@ttrpg.network 2 points 2 weeks ago (1 children)

I usually squash my local into a single commit, then rebase it onto the head of main. Tends to be simpler

[–] cyborganism@lemmy.ca 1 points 2 weeks ago
[–] zalgotext@sh.itjust.works 1 points 2 weeks ago (1 children)

That could happen if the base branch has changed a lot since the last time you rebased against it. Git may make you resolve new conflicts that look similar to the last time you resolved them, but they are in fact new conflicts, as far as git can tell.

[–] cyborganism@lemmy.ca 1 points 2 weeks ago (4 children)

All it can take is one commit in the parent branch. If your branch has many commits because you're a commit freak then your fucked.

load more comments (4 replies)
[–] Artyom@lemm.ee 3 points 2 weeks ago (1 children)

You and I have very different opinions on what is a reasonable expectation for our respective teams.

[–] zalgotext@sh.itjust.works 1 points 2 weeks ago (1 children)

You think it's unreasonable for a software developer to take one to two days to learn a tool that's basically ubiquitous in their field?

[–] Artyom@lemm.ee 2 points 2 weeks ago

No, I think it's a perfectly reasonable thing to do, my coworkers on the other hand...

[–] urquell@lemm.ee 5 points 2 weeks ago (1 children)

And the branch should be alive a shorter period

[–] cyborganism@lemmy.ca 2 points 2 weeks ago
[–] CodexArcanum@lemmy.world 35 points 2 weeks ago (2 children)

To be fair, this is also how VS looks when you open a project fresh from the clone. Or after updating .net versions. .NET is awful about losing references and then claiming thousands of errors. Sometimes just running the build will fix it by relinking the DLLs it couldn't find.

But also yes, VS with a team can be "fun" if people don't sync their formatting settings. I once had a junior that kept converting spaces to tabs on every file he'd touch. You'd get it fixed and then he'd screw up his settings again with a VS update or something.

[–] Vivendi@lemmy.zip 12 points 2 weeks ago

Try programming in Dart. Dart's static analyser and package manager will go nuts 0.0001 seconds before the fucking packages load

[–] FiskFisk33@startrek.website 9 points 2 weeks ago (1 children)
[–] meekah@lemmy.world 2 points 2 weeks ago (1 children)
[–] Appoxo@lemmy.dbzer0.com 8 points 2 weeks ago (1 children)

Tabs > spaces

Tabs does allow you to set the spacing you need.
Spaces are like hardcoding passwords

[–] meekah@lemmy.world 4 points 2 weeks ago (3 children)

Yeah, tabs are larger spaces, what's your point?

/s

You may be right, but I still have an unreasonable hate for tabs in code

[–] Appoxo@lemmy.dbzer0.com 12 points 2 weeks ago (1 children)

And I for spaces.

Let's hate both and be mad at the client?

[–] meekah@lemmy.world 4 points 2 weeks ago

I like the way you think.

[–] fluckx@lemmy.world 5 points 2 weeks ago

Tabs for indenting and spaces for aligning. There. Everybody wins and loses.

This way the code always looks aligned and if you prefer 4 spaces for a tab instead of 2 or 3 or 8 you can just set it in your IDE.

Crisis averted!

load more comments (1 replies)
[–] PotatoesFall@discuss.tchncs.de 20 points 2 weeks ago (1 children)

POV: Your codebase undergoes a full refactor for every feature

[–] SandmanXC@lemmy.world 13 points 2 weeks ago

My codebase doesn't have features, I've been refactoring hello world for 25 years.

[–] netvor@lemmy.world 9 points 2 weeks ago

ALL KINDS OF SUFFERING ARE MERGE CONFLICTS

GIT IS OUR MIRROR

REBASE IS HEAVEN

[–] Gork@lemm.ee 5 points 2 weeks ago
[–] PeriodicallyPedantic@lemmy.ca 4 points 2 weeks ago

I suck at git.
I'm currently rebasing 17k commits into my branch. I'm letting it run overnight.

I'm disgusting.

[–] darki@lemmy.world 2 points 2 weeks ago

Narrator: But it could, in fact, hurt him...

[–] collapse_already@lemmy.ml 2 points 2 weeks ago

I literally make a new branch. clone, and use an external merge tool (beyond compare) when my branch has fallen too far behind. I don't trust any of the automated processes.

[–] No_Support_8363@lemm.ee 2 points 2 weeks ago

If I saw this in my code… I’d just… I’d have a mental breakdown

[–] JATtho@lemmy.world 2 points 2 weeks ago

Jokes on merge.. when a rebase editing goes wrong after +15 commits and six hours, and git hits you with a leadpipe: "do it. Do it again, or reassemble your branch from the reflog." I.e. you commited a change very early, went over bunch of commits resolving/fixing/improving them and at middle way forget if you should commit --amend or rebase --continue to move forward. Choose wrong, and two large change-sets get irreversilbly squashed together (that absolutely shouldn't), with no way to undo. Cheers. 👍

[–] grrgyle@slrpnk.net 1 points 2 weeks ago

rerere makes resolving these almost bearable

load more comments
view more: next ›