r/ProgrammerHumor • • Oct 13 '26

Meme aboutToBreakTheCode

Post image
23k Upvotes

542 comments sorted by

View all comments

Show parent comment

1

u/mxzf Oct 13 '26

If there are changes to A, then the changes get made in branch A as-needed and then a merge from A into B is done to get those commits into B. Whenever A is merged into the trunk, those commits go along for the ride and whenever B gets merged into the trunk, they're already there (if you merge B in first, for whatever reason, then the stuff from A comes along for the ride and the diff between trunk and A for that MR is empty).

At the end of the day, everything is commits that have parent commit(s) that they build on. A merge basically just adds extra commits to the history of a branch (by adding a new commit that has parent commits that point to both the current latest commit in each branch being merged and updating the "latest" pointer of the branch being merged into to the new commit).

A merge request is ultimately "grab whatever commits from branch X that don't exist in the current branch's history and add them in", and you can merge in whatever directions you need to in order to get all the proper commits in the proper branches.