Rebase Supremacy
Rebase Supremacy
Rebase Supremacy
I think this is a fake quote that somebody made up for an Internet comedy bit, since it seems unlikely for Hollywood actress Sydney Sweeney to have such uncharacteristically strong opinion on software version control, of all things.
Because she of all people would know that there isn't anything wrong with using git merge
, and it ultimately comes down to personal preference to what you are used to.
Fair point, Margot Robbie
That's esteemed Academy Award nominated character actress Margot Robbie to you!
Margot Robbie, I was about to agree with you and thought that was a very reasonable take, until you tried to argue that git merge
is better than git rebase
, then I simply had to disregard the whole thing.
This is why Sydney Sweeney isn't on Lemmy.
But they were arguing that it's personal preference not that one is better than the other
"Don't always trust what you read on the internet."
Wait a second, there wasn't even any social media sites back when Benjamin Franklin lived. Did he write that in his newsletter or something?
But esteemed Academy Award nominated character actress and film director, Margot Robbie, if it's unlikely that Hollywood actress Sydney Sweeney said this... wouldn't it be just as unlikely that Margot Robbie would be here? Adding her own comment?
... are you projecting? Is there something you want to tell us esteemed Academy Award nominated character actress and film director Margot Robbie?
I think this is a fake quote that somebody made up for an Internet comedy bit
You can tell by the pixels
No, the tweet is real. Just not the quote.
I mean, it’s posted in programming humor so yeah.
A bit of the old on the internet no-one knows you're a dog, I think. Therefore I am a webdev dog too.
Why is anyone using X in 2024?
I do, I have yet to switch to Wayland
It's called Twitter now, by conservation of names. /s
Shit, I unironically thought they were talking about this, and I unironically haven’t switched because Barrier is broken on Wayland
I use X because Cinnamon on Wayland has no option to change the keyboard layout
I tried their experimental Wayland session and it's still super buggy on high refresh rate/high DPI screens (loads of graphical errors and artifacts) so still a ways to go imo
Wayland really doesn't like RDP/remote access, so X is the only way to go if you want that to work properly.
I actually never had an issue on my wayland system. I used remmina for rdp but never had an issue.
I tried it for a moment, made games stutter like hell, switched back. I know I need to go in and figure it out at some point, but it's hard to muster the energy when X, for the most part, works fine.
From what I've seen, it probably has to do with my Nvidia GPU.
I'm currently at the point where I blame everything that works on my Laptop but not on my PC on Nvidia, because that's literally the biggest difference between those two. Like currently my getty isn't displaying properly, which is surely NVidias fault.
Odd, when i switched to Wayland the stuttering stopped! Also on Nvidia
Because my new intel integrated graphics cause Wayland to run like a slideshow.
because some of the hardware I use is too old to run Wayland
Idk I hang out on Mastodon.social
If yall don't like the chronological feed then find a hashtag you like and start following people.
Because their name is Elon Musk.
No censorship tbh
But there is blatant censorship
Imagine rewring history
History is written by the squashers.
Imagine working with a tangled spaghetti of history
You don't? Just follow the merges.
You try to pull someone's changes, but whoops, they used rebase and rewrote history! Delete the branch and start over.
No you just do a rebase to bring it in. Assuming you’re making atomic commits you shouldn’t have a ton of merge conflicts. If you have to do this a lot, your branch scope is really bad and the problem isn’t in how you’re using got, it’s in how you’re slicing work.
2 things:
git pull --rebase
. Works without issue. I prefer to rebase as well. But when you're working with a team of amateurs who don't know how to use a VCS properly and never update their branc with the parent branch, you end up with lots of conflicts.
I find that for managing conflicts, rebase is very difficult as you have to resolve conflicts for every commit. You can either use rerere to repeat the conflict resolution automatically, or you can squash everything. But when you're dealing with a team of Git-illiterate developers (which is VERY often the case) you can either spend the time to educate them and still risk having problems because they don't give a shit, or you can just do a regular merge and go on with your life.
Those are my two cents, speaking from experience.
I agree that merge is the easier strategy with amateurs. By amateurs I mean those who cannot be bothered to learn about rebase. But what you really lose there is a nice commit history. It's good to have, even if your primary strategy is merging. And people tend to create horrendous commit histories when they don't know how to edit them.
Honestly, I'm pretty sure 99.9% of git users never really bother with the git history in any way that would be hindered by merging.
Git has a ton of powerful features, but for most projects they don't matter at all. You want a distributed consensus, that's it. Bothering yourself with all those advanced features and trying to learn some esoteric commands is frankly just overhead. Yes, you can solve great problems with them, but these problems almost never occur, and if they do, using the stupid tools is faster overall.
Why would you want to edit your commit history? When I need to look at it for some reason, I want to see what actually happened, not a fictional story.
How others are keeping their branches up to date is their problem. If you use Gitlab you can set up squash policy for merge requests. All the abomination they’ve caused in their branch will turn into one nice commit to the main branch.
In a small team at a small company it becomes my problem pretty quickly, since I'm the only one that actually has some clue about what git does.
I don't want squashed commits. It makes git tools worse (git bisect
, git cherry-pick
, etc.) and I work very hard to craft a meaningful set of commits for my work and I don't want to throw all of that away.
But yeah, I don't actually give a shit what they are doing on their branches. I regularly rebase onto master anyway.
Git-
illeterateilliterate
Ah thanks.
Please for the love of god don't use merge, especially in a crowded repository. Don't be me and suffer the consequences. I mistakenly mention every person with a commit between the time I created the branch until current master.
That was you! I remember this.
AAAH NOT LIKE THIS
Could have been worse. I mean, like, imagine of you were using like CVS and you put a watch on the root! Haha and then like every trivial commit in the repo caused everyone to in the entire org to get an email and it crashed the email servers.
Like who'd even DO that?! Though, I bet if you met that guy he'd be ok. Like not a jerk, and pretty sorry for all those emails. A cool guy.
Merge is not the issue here, rebase would do the same.
really? how come? I thought they are mentioned because of the diffs if compared to master, which merge basically just... merge on top of my branch (?)
You sent over twenty-two thousand notifications lmao.
And then the bot added about as many tags to the PR.
ITT: people who have no idea how rebasing works.
Skill issue tbh
No doubt. git rebase
is like a very sharp knife. In the right hands, it can accomplish great things, but in the wrong hands, it can also spell disaster.
As someone who HAS used it a fair amount, I generally don't even recommend it to people unless they're already VERY comfortable with the rest of git and ideally have some sense of how it works internally.
Okay this is the second time I've seen Sydney Sweeney referenced in a meme in less than half a day. I had never heard of her before. Who is she, and why is she suddenly attracting so much meme attention?
She's an Australian American actress who blew up last year (she was in euphoria I think?), expect to see her in a ton of upcoming blockbusters.
You are probably thinking of another talented blonde Australian actress.
She is from Spokane Washington not Australia. She got a lot of recognition for her role in Euphoria and is blowing up a bit right now because she is a young, attractive, talented actress.
She was excellent in the first season of White Lotus on Sky too. Great show.
Her blown up remains you mean?
She also has a pair of massive blockbusters
She's an American actress who was in Handmaid's Tale and a few other things and then blew up thanks to her role in Euphoria. She's become a bit of a meme recently because online conservatives think that her boobs are anti-woke
What a bizarre story. Mr. W is me right now:
Two reasons.
Rebasing is for noobs.
undefined
git reset head~42 git push -f
Holy shit
I've been using merge, and I hate that I don't even know what rebase really does
Merge takes two commits and smooshes them together at their current state, and may require one commit to reconcile changes. Rebase takes a whole branch and moves it, as if you started working on it from a more recent base commit, and will ask you to reconcile changes as it replays history.
This diagram seems wrong to me. Isn't the second image a squash merge? Also why would rebasing a feature branch change main?
I'm relatively new to git and rebase looks like a mess to me? Like it appears to be making duplicate commits and destroys the proper history?
If you use rebase to get a more readable history, isn't the issue the tool you use to view the history?
I guess I have to try it out a few times to get it.
That's pretty cool, might actually do that. Tho, we currently don't use the history as much anyways, we're just having a couple of small student projects with the biggest group being 6 people. I guess it's more useful if you're actually making a real product in a huge project that has a large team behind it
Merge is taking all the code from the master branch and combining it with the task branch, resulting in a commit for just the merge itself.
Rebase is "re-basing" where your task branch was created from off the master branch. It essentially takes all the commits from master that happened since you branched, REWRITES THE HISTORY of your task branch by inserting those master branch commits before all your existing commits, and effectively makes your task branch look like it was branched yesterday instead of like 4 weeks ago. You changed where your task branch originated on the master. You moved its base.
Atlassian does a fantastic writeup on this.
So kinda like as if you had kept your branch synced the whole time?
So, with a merge you basically shuffle in the changes from both branches, but a rebase takes only the changes from one branch and puts it over the other? Edit: no. Read wrong. I should probably watch a vid about it or something
Did she just tell people up git good?
I know this is a meme post, but can someone succinctly explain rebase vs merge?
I am an amateur trying to learn my tool.
Merge keeps the original timeline. Your commits go in along with anything else that happened relative to the branch you based your work off (probably main
). This generates a merge commit.
Rebase will replay all the commits that happened while you were doing your work before your commits happen, and then put yours at the HEAD, so that they are the most recent commits. You have to mitigate any conflicts that impact the same files as these commits are replayed, if any conflicts arise. These are resolved the same way any merge conflict is. There is no frivolous merge commit in this scenario.
TlDR; End result, everything that happened to the branch minus your work, happens. Then your stuff happens after. Much tidy and clean.
Thanks for the explanation. It makes sense. To my untrained eyes, it feels like both merge and rebase have their use. I will try to keep that in mind.
Merge gives an accurate view of the history but tends to be "cluttered" with multiple lines and merge commits. Rebase cleans that up and gives you a simple A->B->C view.
Personally I prefer merge because when I'm tracking down a bug and narrow it down to a specific commit, I get to see what change was made in what context. With rebase commits that change is in there, but it's out of context and cluttered up with zillions of other changes from the inherent merges and squashes that are included in that commit, making it harder to see what was changed and why. The same cluttered history is still in there but it's included in the commits instead of existing separately outside the commits.
I honestly can't see the point of a rebased A->B->C history because (a) it's inaccurate and (b) it makes debugging harder. Maybe I'm missing some major benefit? I'm willing to learn.
I feel the opposite, but for similar logic? Merge is the one that is cluttered up with other merges.
With rebase you get A->B->C for the main branch, and D->E->F for the patch branch, and when submitting to main you get a nice A->B->C->D->E->F and you can find your faulty commit in the D->E->F section.
For merge you end up with this nonsense of mixed commits and merge commits like A->D->B->B'->E->F->C->C' where the ones with the apostrophe are merge commits. And worse, in a git lot there is no clear "D E F" so you don't actually know if A, D or B came from the feature branch, you just know a branch was merged at commit B'. You'd have to try to demangle it by looking at authors and dates.
The final code ought to look the same, but now if you're debugging you can't separate the feature patch from the main path code to see which part was at fault. I always rebase because it's equivalent to checking out the latest changes and re-branching so I'm never behind and the patch is always a unique set of commits.
I would advocate for using each tool, where it makes sense, to achieve a more intelligible graph. This is what I've been moving towards on my personal projects (am solo). I imagine with any moderately complex group project it becomes very difficult to keep things neat.
In order of expected usage frequency:
History should be viewable from log --all --decorate --oneline --graph; not buried in squash commits.
Folks should make sure the final series of commits in pull requests have atomic changes and that each individual commit works and builds successfully alone. Things like fixup commits with auto squash rebase. THIS WAY you can still narrow it down to one commit regardless of the approach.
I used to only merge. Now I rebase. The repo is set up to require squash and rebase when going to main.
All the garbage "spelled thing wrong" and "ran formatter" commits go away. Main is clean and linear.
Squash and rebase or squash or rebase?
..and? You squash so all your gross "isort" "forgot to commit this file" "WIP but I'm getting lunch" commits can be cleaned up into a single "Add endpoint to allow users to set their blah blah" comment with a nice extended description.
You then rebase so you have a nice linear history with no weird merge commits hanging around.
I'll go one further: use git rebase --interactive
I remember learning about how to use this back in the day and what a game changer it was for my workflow.
Today I like to do all of the commits as I’m working. Maybe dozens or more as I chug along, marking off waypoints rather than logging actual changes. When I’m done a quick interactive rebase cleans up the history to meaningful commits quite nicely.
The fun part is that I will work with people sometimes who both swear that “rewriting history” is evil and should never be done, but also tell me how useful my commit logs are and want to know how I take such good notes as I go.
Argh. I hate that argument.
Yes - "Rewriting history" is a Bad Thing - but o argue that's only on 'main' (or other shared branches). You should (IMHO) absolutely rewrite your local history pre-push for exactly the reasons you state.
If you rewrite main's history and force your changes everybody else is gonna have conflicts. Also - history is important for certain debugging and investigation. Don't be that guy.
Before you push though... rebasing your work to be easily digestible and have a single(ish) focus per commit is so helpful.
I use a stacked commit tool to help automate rebasing on upstream commits, but you can do it all with git pretty easily.
Anyway. Good on you; Keep the faith; etc etc. :)
At my company we just use a squash policy in gitlab. Every merge request becomes a single commit to the main branch. Super easy to read the commit log because all commits are descriptive instead of a bunch of “fix MR comments” or “fix pipeline errors”.
Another advice: git reset [commit-id]
followed with a git commit -a
is a quick way to squash all your commits.
Even better, master creating fixup and squash commits and maintain logical commits as you work with git rebase -i --autosquash
This is really the only sane way to do it. I have run into some wonkyness with the commit history of the target branch commits not resembling git log
, but that's usually for commits outside of what I'm trying to merge.
Edit: squashing commits down this way also helps reduce problems with replaying commit history on the actual rebase. In most cases you don't need all your "microcommits" in the history, and fewer commits just takes less time to reconcile.
git merge --no-ff
git config --global merge.ff no
Heres my based af workflow:
git checkout -b feature-branch
rebase on top of dev whilst working locally
git rebase origin/dev-branch && git push -f
if i need to fix conflicts with dev-branch during a PR
git merge origin/dev
I have been using something very similar to this. In my team I insisted on people without any git experience working on a separate local branch, than the feature branch
. To ensure screw ups are minimal, we pull and create a local feature branch and then a new local only dummy branch, on top of it. Once the team is more comfortable with git, I am planning to treat the local feature branch as a dummy branch.
So far things have been pretty neat. Spaghetti is no more with minimal conflicts.
Anyone mind explaining to me how git rebase
is worth the effort?
git merge
has it's own issues but I just don't see any benefit to rebase over it.
I use interactive rebases to clean up the history of messy branches so they can be reviewed commit by commit, with each commit representing one logical unit or type of change.
Mind you, getting those wrong is a quick way to making commits disappear into nothingness. Still useful if you're careful. (Or you can just create a second temporary branch you can fall back onto of you need up your first once.)
This 100%. I hate getting added to a PR for review with testing commits in the history, and I'm expected to clean those up before merging into main.
Well, rebase allows you to resolve the same conflict ten times in a row instead of doing it once. How cool is that?
Nope, you just need to do it once: https://git-scm.com/book/en/v2/Git-Tools-Rerere.
Squash your branch first
Only before you collaborate with anyone else. After that, don't ever use rebase, or they'll get an error, and will have to overwrite their local history with the one you've rewritten.
The way I structure my commits, it is usually (but not always) easier and more reliable for me to replay my commits one at a time on top of the main branch and see how each relatively small change needs to be adapted in isolation--running the full test suite at each step to verify that my changes were correct--than to be presented with a slew of changes all at once that result from marrying all of my changes with all of the changes made to the main branch at once. So I generally start by attempting a rebase and fall back to a merge if that ends up creating more problems than it solves.
git rebase
is only for terrorists. 🥸
Also for me when I’ve been drinking and committed some really stupid shit into the repo. No one needs to know what I really think of my team members.
Yeah totally merge everything, people like a good spaghetti salad.
spaghetti salad
Found the German :D
Fuck a merge commit! Rebase ervray day bay bayyy.
Rebase feature branch, merge commit into main
(NO SQUASH).
make the commit message be "we’ve fixed bugs and improved performance. to experience the newest features and improvements, checkout the latest version of the branch."
great new features
Jia Tan
I personally prefer "git off my lawn"
Ah, yes, the good old git off --my lawn
command.
You had me a "Sydney Sweeney reveals".
I like rebase, it's everyone else that hate it when I rebase main
twice a day.
Daily circlejerk
i like to create ten different checkouts of main, rebase them all slightly differently and then no fast forward merge them all back into each other
I know how to use git pull, git push, git commit, git status and git add *. I don't even know how git commit and git push works I just know you run them in that order. Whenever I break everything I give up and go outside.
I like the idea of it and there were times i used it correctly, but most of the time i do it wrong i guess.
do it often. you may end up with 150 conflicts to have to wade through.
To produce 1 commit, I end up rebasing the damm thing at least 3 times. If there is an problem, it's at least 2³ times.