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.
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.
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 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
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 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.
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.
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.
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.
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.
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 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'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
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.
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.
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
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.
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:
Rebase: everything that's not 2 or 3.
keep main and feature lines clean.
Merge: ideally, merge should only be used to bring
feature branches into main at stable sequence points.
Squash: only use squash to remove history that truly
is useless. (creating a bug on a feature branch and
then solving it two commits later prior to merge).
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.
..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 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.
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.
review is easier since concerns aren't mixed
If a commit needs to be reverted it limits the collateral damage
history is easier to follow because the commits tell a story
I use a stacked commit tool to help automate rebasing on upstream commits, but you can do it all with git pretty easily.
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.
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.
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.
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.)
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.
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."
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.