• katy ✨
      link
      fedilink
      41 year ago

      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.”

  • 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.

    • @droans@lemmy.world
      link
      fedilink
      21 year ago

      You sent over twenty-two thousand notifications lmao.

      And then the bot added about as many tags to the PR.

    • Atemu
      link
      fedilink
      51 year ago

      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 (?)

        • Atemu
          link
          fedilink
          21 year ago

          They were mentioned because a file they are the code owner of was modified in the PR.

          The modifications came from another branch which you accidentally(?) merged into yours. The problem is that those commits weren’t in master yet, so GH considers them to be part of the changeset of your branch. If they were in master already, GH would only consider the merge commit itself part of the change set and it does not contain any changes itself (unless you resolved a conflict).

          If you had rebased atop of the other branch, you would have still had the commits of the other branch in your changeset; it’d be as if you tried to merge the other branch into master + your changes.

          • @Bourff@lemmy.world
            link
            fedilink
            -1
            edit-2
            1 year ago

            Just for the record, I think you’re conflating git and GitHub. They are not the same thing, even if GH would like you to think so.

    • @jaemo@sh.itjust.works
      link
      fedilink
      111 year ago

      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.

    • @letsgo@lemm.ee
      link
      fedilink
      181 year ago

      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.

      • @ActionHank@sopuli.xyz
        link
        fedilink
        3
        edit-2
        1 year ago

        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:

        1. Rebase: everything that’s not 2 or 3. keep main and feature lines clean.
        2. Merge: ideally, merge should only be used to bring feature branches into main at stable sequence points.
        3. 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.

      • @reflectedodds@lemmy.world
        link
        fedilink
        16
        edit-2
        1 year ago

        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.

        • Atemu
          link
          fedilink
          41 year ago

          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.

          Your notation does not make sense. You’re representing a multi-dimensional thing in one dimension. Of course it’s a mess if you do that.

          Your example is also missing a crucial fact required when reasoning about merges: The merge base.
          Typically a branch is “branched off” from some commit M. D’s and A’s parent would be M (though there could be any amount of commits between A and M). Since A is “on the main branch”, you can conclude that D is part of a “patch branch”. It’s quite clear if you don’t omit this fact.

          I also don’t understand why your example would have multiple merges.

          Here’s my example of a main branch with a patch branch; in 2D because merges can’t properly be represented in one dimension:

          M - A - B - C - C'
            \           /
              D - E - F
          

          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.

          If you use a feature branch workflow and your main branch is merged into, you typically want to use first-parent bisects. They’re much faster too.

          • @reflectedodds@lemmy.world
            link
            fedilink
            21 year ago

            You’re right, I’m not representing the merge correctly. I was thinking of having multiple merges because for a long running patch branch you might merge main into the patch branch several times before merging the patch branch into main.

            I’m so used to rebasing I forgot there’s tools that correctly show all the branching and merges and things.

            Idk, I just like rebase’s behavior over merge.

            • Atemu
              link
              fedilink
              41 year ago

              The thing is, you can get your cake and eat it too. Rebase your feature branches while in development and then merge them to the main branch when they’re done.

      • JackbyDev
        link
        fedilink
        English
        11 year ago

        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.

    • @jaemo@sh.itjust.works
      link
      fedilink
      231 year ago

      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.

      • @Croquette@sh.itjust.works
        link
        fedilink
        61 year ago

        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.

        • @aubeynarf@lemmynsfw.com
          link
          fedilink
          111 months ago

          Never use rebase for any branch that has left your machine (been pushed) and which another entity may have a local copy of (especially if that entity may have committed edits to it).

        • @bitcrafter@programming.dev
          link
          fedilink
          31 year ago

          Yes. My rule of thumb is that generally rebasing is the better approach, in part because if your commit history is relatively clean then it is easier to merge in changes one commit at a time than all at once. However, sometimes so much has changed that replaying your commits puts you in the position of having to solve so many problems that it is more trouble than it is worth, in which case you should feel no qualms about aborting the rebase (git rebase --abort) and using a merge instead.

          • @Croquette@sh.itjust.works
            link
            fedilink
            11 year ago

            I have the bad habit of leaving checkpoints everywhere because of merge squash that I am trying to fix. I think that forcing myself to rebase would help get rid of that habit. And the good thing is that I am the sole FW dev at work, so I can do whatever I want with the repos.

        • JackbyDev
          link
          fedilink
          English
          61 year ago

          Yes. They do. A lot of people will use vacuous terms like “clean history” when arguing for one over the other. In my opinion, most repositories have larger problems than rebase versus merge. Like commit messages.

          Also, remember, even if your team/repository prefers merges over rebases for getting changes into the main branch, that doesn’t mean you shouldn’t be using rebase locally for various things.

          • @Croquette@sh.itjust.works
            link
            fedilink
            21 year ago

            How would rebasing my own branch work? Do I rebase the main into my branch, or make a copy of the main branch and then rebase? I have trouble grasping how that would work.

            • @jaemo@sh.itjust.works
              link
              fedilink
              21 year ago

              Here’s an example

              Say I work on authentication under feature/auth Monday and get some done. Tuesday an urgent feature request for some logging work comes in and I complete it on feature/logging and merge clean to main. To make sure all my code from Monday will work, I will then switch to feature/auth and then git pull --rebase origin main. Now my auth commits start after the merge commit from the logging pr.

            • JackbyDev
              link
              fedilink
              English
              31 year ago

              You’re still rebasing your branch onto main (or whatever you originally branched it off of), but you aren’t then doing a fast forward merge of main to your branch.

              The terminology gets weird. When people say “merge versus rebase” they really mean it in the context of brining changes into main. You (or the remote repository) cannot do this without a merge. People usually mean “merge commit versus rebase with fast forward merge”

              • @Croquette@sh.itjust.works
                link
                fedilink
                11 year ago

                Yeah I was confused because you are right, merge is usually refered as the git merge and then git commit.

                It makes sense. Thanks for the clarification

            • JackbyDev
              link
              fedilink
              English
              21 year ago

              I must have read that blog post in the past because that’s exactly the style I use. Much of it is standard though.

              One MAJOR pet peeve of mine (and I admit it is just an opinion either way) is when people use lower case letters for the first line of the commit message. They typically argue that it is a sentence fragment so shouldn’t be capitalized. My counter is that the start of sentences, even fragmented ones, should be capitalized. Also, and more relevant, is that I view the first line of the commit more like the title of something than a sentence. So I use the Wikipedia style of capitalizing.

              • @jaemo@sh.itjust.works
                link
                fedilink
                11 year ago

                https://gitmoji.dev/

                Quasi parallel reply to your other post, this would kind of echo the want for a capital letter at the start of the commit message. Icon indicates overall topic nature of commits.

                Lets say I am adding a database migration and my commit is the migration file and the schema. My commit message might be:

                     🗃️ Add notes to Users table
                

                So anyone looking at the eventual pr will see the icon and know that this bunch of work will affect db without all that tedious “reading the code” part of the review, or for team members who didn’t participate in reviews.

                I was initially hesitant to adopt it but I have very reasonable, younger team mates for whom emojis are part of the standard vocabulary. I gradually came to appreciate and value the ability to convey more context in my commits this way. I’m still guilty of the occasionally overusing:

                   ♻️ Fix the thing
                

                type messages when I’m lazy; doesn’t fix that bad habit, but I’m generally much happier reading mine or someone else’s PR commit summary with this extra bit of context added.

                • Deebster
                  link
                  fedilink
                  11 year ago

                  I looked at it and there’s a lot of them!

                  I see things like adding dependencies but I would add the dependency along with the code that’s using it so I have that context. Is the Gitmoji way to break your commits up so that it matches a single category?

        • @jaemo@sh.itjust.works
          link
          fedilink
          51 year ago

          100% they do. Rebase is an everyday thing, merge is for PRs (for me anyway). Or merges are for regular branches if you roll that way. The only wrong answer is the one that causes you to lose commits and have to use reflog, cos…well, then you done messed up now son… (but even then hope lives on!)

  • Margot Robbie
    link
    fedilink
    2131 year ago

    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.

    • @Artyom@lemm.ee
      link
      fedilink
      541 year ago

      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.

      • Margot Robbie
        link
        fedilink
        791 year ago

        That’s esteemed Academy Award nominated character actress Margot Robbie to you!

        • Sundray
          link
          fedilink
          English
          191 year ago

          And successful Hollywood film producer – props on getting into the stakeholder end of the business so early in your career!

    • René Descartes
      link
      fedilink
      31 year ago

      A bit of the old on the internet no-one knows you’re a dog, I think. Therefore I am a webdev dog too.

    • @hactar42@lemmy.world
      link
      fedilink
      121 year ago

      I think this is a fake quote that somebody made up for an Internet comedy bit

      You can tell by the pixels

      • TJA!
        link
        fedilink
        2
        edit-2
        1 year ago

        No, the tweet is real. Just not the quote.

      • @ManniSturgis@lemmy.zip
        link
        fedilink
        111 year ago

        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?

    • @Jax@sh.itjust.works
      link
      fedilink
      251 year ago

      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?

    • @BlackPenguins@lemmy.world
      link
      fedilink
      20
      edit-2
      1 year ago

      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.

        • @BlackPenguins@lemmy.world
          link
          fedilink
          7
          edit-2
          1 year ago

          Kind of. Both merge and rebase result in the branches “synced up” but they do it in different ways.

          Merge is making a batter for cookies, having a bowl for dry ingredients (task branch) and a bowl for wet ingredients, (master branch) making them separately and then just dumping the dry bowl into the wet bowl (merge).

          Rebase is taking a time machine back to before you started mixing the dry ingredients, mix all the wet ingredients first then add the dry ones on top of that in the same bowl.

          It’s really hard to create an analogy for this.

      • @Crow@lemmy.blahaj.zone
        link
        fedilink
        1
        edit-2
        1 year ago

        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

    • andrew
      link
      fedilink
      English
      52
      edit-2
      1 year ago

      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.

      • Elise
        link
        fedilink
        51 year ago

        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.

        • Ephera
          link
          fedilink
          51 year ago

          What you probably mean by duplicate commits is that it assigns new commit IDs to commits that have been rebased. If you had already pushed those commits, then git status will tell you that the remote branch and your local branch have diverged by as many commits as you rebased.

          Well, and what is the “proper history”? If your answer is “chronological”, then why so?
          For the rare times that it matters when exactly a commit was created, they’ve got a timestamp. But otherwise, the “proper history” is whatever you make the proper history. What matters is that the commits can be applied one after another, which a rebase ensures.

          When you’re working on a branch and you continuously rebase on the branch you want to eventually merge to, then the merged history will look as if you had checked out the target branch and just made your commits really quickly without anyone else committing anything in between.
          And whether you’ve done your commits really quickly or over the course of weeks, that really shouldn’t matter.

          What is really cool about (supposedly) making commits really quickly is that your history becomes linear and it tells a comprehensible story. It won’t be all kinds of unrelated changes mixed randomly chronologically, but rather related commits following one another.
          And of course, you also lose the merge-commits, which convey no valuable information of their own.

          • Atemu
            link
            fedilink
            21 year ago

            you also lose the merge-commits, which convey no valuable information of their own.

            In a feature branch workflow, I do not agree. The merge commit denotes the end of a feature branch. Without it, you lose all notion of what was and wasn’t part of the same feature branch.

            • @someonesmall@lemmy.ml
              link
              fedilink
              11 year ago

              Agreed, you also lose the info about the resolved merge conflicts during the merge (which have been crucial a few times to me).

              • Ephera
                link
                fedilink
                English
                11 year ago

                Well, with a rebase workflow, there should be no merge conflicts during the final merge. That should always be a fast-forward.

                Of course, that’s because you shift those merge conflicts to occur earlier, during your regular rebases. But since they’re much smaller conflicts at a time, they’re much easier to resolve correctly, and will often be auto-resolved by Git.

                You’re still right, that if you’ve got a long-running feature branch, there’s a chance that a conflict resolution broke a feature that got developed early on, and that does become invisible. On the flip-side, though, the person working on that feature-branch has a chance to catch that breakage early on, before the merge happens.

        • AggressivelyPassive
          link
          fedilink
          31 year ago

          The commits aren’t duplicated, but applied to the main branch. Since git has commit ids, they won’t be re-rebased either.

        • Atemu
          link
          fedilink
          21 year ago

          The only difference between a *rebase-merge and a rebase is whether main is reset to it or not. If you kept the main branch label on D and added a feature branch label on G’, that would be what @andrew@lemmy.stuart.fun meant.

        • andrew
          link
          fedilink
          English
          31 year ago

          Yeah, the image (not mine, but the best I found quickly) kinda shows a rebase+merge as the third image. As the other commenter mentioned, the new commit in the second image is the merge commit that would include any conflict resolutions.

        • @bort@sopuli.xyz
          link
          fedilink
          21 year ago

          why would rebasing a feature branch change main?

          the image does not update the feature branch. It merges the featurebranch into main with a regular old merge-commit on the main branch.

      • @Crow@lemmy.blahaj.zone
        link
        fedilink
        61 year ago

        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

        • @RecluseRamble@lemmy.dbzer0.com
          link
          fedilink
          5
          edit-2
          1 year ago

          Just remember to not combine it with force push or you’re in for some chaos (rewriting history team members have already fetched is a big no-no).

            • @expr@programming.dev
              link
              fedilink
              3
              edit-2
              1 year ago

              Or, you know, on your own feature branch to clean up your own commits. It’s much, much better than constantly littering your branch’s history with useless merge commits from upstream, and it lets you craft a high-quality, logical commit history.

              • Of course it has its uses. I didn’t mention them because the guy just learned about rebase - it’s unlikely to be applied flawlessly from the start.

                • @expr@programming.dev
                  link
                  fedilink
                  11 year ago

                  I was replying to the other comment, not yours. Though there’s not really a way of using rebasing without force pushing unless it’s a no-op.

                  Rebasing is really not a big deal. It’s not actually hard to go back to where you were, especially if you’re using git rebase --interactive. For whatever reason people don’t seem to get that commits aren’t actually ever lost and it’s not that hard to point HEAD back to some previous commit.

              • You can do all that without force push. Just make a new branch and do the cleanup before the first push there. Allowing force push just invites disaster from junior developers who don’t know what they’re doing. If you want to clean up after them, that’s your business, I guess.

                • @expr@programming.dev
                  link
                  fedilink
                  11 year ago

                  That’s exactly the same thing. A branch is nothing more than a commit that you’ve given a name to. Whether that name is your original branch’s name or a new branch’s name is irrelevant. The commit would be the same either way.

                  A junior cannot actually do any real damage or cause any actual issue. Even if they force push “over” previous work (which again, is just pointing their branch to a new commit that doesn’t include the previous work), that work is not lost and it’s trivial to point their branch to the good commit they had previously. It’s also a good learning opportunity. The only time you actually can lose work is if you throw away uncommitted changes, but force pushing or not is completely irrelevant for that.

            • @zalgotext@sh.itjust.works
              link
              fedilink
              11 year ago

              Force pushes are perfectly safe if you’re working on your own branch, and even if you’re sharing a branch, you can still force push to it as long as you inform and coordinate with whoever else is working on that branch.

        • @ScreaminOctopus@sh.itjust.works
          link
          fedilink
          English
          31 year ago

          I wouldn’t recommend it. The Git documentation itself doesn’t recommend rebase for more than moving a few unpushed commits to the front of a branch you are updating. Using it by default instead of merge requires you to use --force-push as part of your workflow which can lead to confusing situations when multiple developers end up commiting to the same branch, and at worst can lead to catastrophic data loss. The only benefit is a cleaner history graph, which is rarely used anyway, and you can always make the history graph easier to read with a gui without incuring any of the problems of rebase.

          • @surge_1@lemmy.world
            link
            fedilink
            61 year ago

            Bad take IMO,

            At 10+ YOE, I use rebase almost exclusively. Branch from main, rebase to clean up commit history before putting up a PR. If commits are curated properly you don’t run into conflicts very often. Branches really shouldn’t be shared too often anyway, and the ones that are should be write protected.

            Catastrophic data loss isn’t really possible either with git since it’s all preserved and you can git reflog even if you mess up.

            The meme is right. Git good

            • AggressivelyPassive
              link
              fedilink
              01 year ago

              Years of experience don’t really matter here, that’s just call to authority, in this case yourself. You might as well be the worst git user ever after 20 years of usage, or the best after 2. We don’t know that.

              Anyway, what you’re saying basically requires a perfect world to be true. Feature branch flow is perfectly fine, but you do end up with merge conflicts constantly, unless you have cordoned off areas of the repo for certain users. Two people working on unrelated features, both change a signature of some helper/util method, merge conflict. Nothing serious, can be fixed in a minute, and rebasing or merging won’t help for either.

              Merge is perfectly fine. And arguing about which strategy to use is one of those autistic debates we as an industry seemingly love to have. It doesn’t matter, but you’ll find people screaming at each other about it. See Emacs vs. Vi. Same crap.

              • @surge_1@lemmy.world
                link
                fedilink
                01 year ago

                Merge is fine, but not knowing both rebase and merge is dumb. And I guess I’ve been in a perfect world this whole time in huge technical orgs lol.

            • @Croquette@sh.itjust.works
              link
              fedilink
              11 year ago

              When rebasing, it applies the changes without the commit history?

              Does that mean that when you fast forward your main/dev branch and commit, you then add a single commit that encompasses every changes that were rebase?

              • @expr@programming.dev
                link
                fedilink
                2
                edit-2
                1 year ago

                No, there are no fast-forwards with rebasing. A rebase will take take the diff of each commit on your feature branch that has diverged from master and apply those each in turn, creating new commits for each one. The end result is that you have a linear history as though you had branched from master and made your commits just now.

                If you had branched like this:

                A -> B -> C (master)
                   \
                     \ -> D (feature)
                

                It would like this after merging master into your feature branch:

                A -> B -> C (master) ->   E (feature)
                  \                                    /
                    \ -> D -------------------> /
                

                And it would like this if you instead rebased your feature branch onto master:

                A -> B -> C (master) -> D' (feature)
                

                This is why it’s called a “rebase”: the current state of master becomes the starting point or “base” for all of your subsequent commits. Assuming no conflicts, the diff between A and D is the same as the diff between A and D'.

          • @expr@programming.dev
            link
            fedilink
            51 year ago

            This a really bad take and fundamentally misunderstands rebasing.

            First off, developers should never be committing to the same branch. Each developer maintains their own branch. Work that needs to be tested together before merging to master belongs on a dedicated integration branch that each developer merges their respective features branches into. This is pretty standard stuff.

            You don’t use rebasing on shared branches, and no one arguing for rebasing is suggesting you do that. The only exception might be perhaps a dedicated release manager preparing a release or a merge of a long-running shared branch. But that is the kind of thing that’s communicated and coordinated.

            Rebasing is for a single developer working on a feature branch to produce a clean history of their own changes. Rebasing in this fashion doesn’t touch any commits other than the author’s. The purpose is to craft a high quality history that walks a reader through a proposed sequence of logical, coherent changes.

            Contrary to your claim, a clean history is incredibly valuable. There’s many tools in git that benefit significantly from clean, well-organizes commits. git bisect, git cherry-pick… Pretty much any command that wants to pluck commits from history for some reason. Or even stuff like git log -L or git blame are far more useful when the commit referenced is not some giant amalgamation of changes from all over the place.

            When working on a feature branch, if you’re merging upstream into your branch, you’re littering your history with pointless, noisy commits and making your MR harder to review, in addition to making your project’s history harder to understand and navigate.

  • @jjjalljs@ttrpg.network
    link
    fedilink
    161 year ago

    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.

      • @jjjalljs@ttrpg.network
        link
        fedilink
        61 year ago

        …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.

        • @cobra89@beehaw.org
          link
          fedilink
          11 year ago

          Okay honest question, when you merge a PR in GitHub and choose the squash commits box is that “rebasing”? Or is that just squashing? Because it seems that achieves the same thing you’re talking about.

          • @jjjalljs@ttrpg.network
            link
            fedilink
            31 year ago

            There’s two options in the green button on a pr. One is squash and merge, the other is squash and rebase.

            Squashing makes one commit out of many. You should IMO always do this when putting your work on a shared branch

            Rebase takes your commit(s) and sticks them on the end.

            Merge does something else I don’t understand as well, and makes a merge commit.

            Also there was an earthquake in NYC when I was writing this. We may have angered the gods.

            • Atemu
              link
              fedilink
              01 year ago

              You should IMO always do this when putting your work on a shared branch

              No. You should never squash as a rule unless your entire team can’t be bothered to use git correctly and in that case it’s a workaround for that problem, not a generally good policy.

              Automatic squashes make it impossible to split commit into logical units of work. It reduces every feature branch into a single commit which is quite stupid.
              If you ever needed to look at a list of feature branch changes with one feature branch per line for some reason, the correct tool to use is a first-parent log. In a proper git history, that will show you all the merge commits on the main branch; one per feature branch; as if you had squashed.

              Rebase “merges” are similarly stupid: You lose the entire notion of what happened together as a unit of work; what was part of the same feature branch and what wasn’t. Merge commits denote the end of a feature branch and together with the merge base you can always determine what was committed as part of which feature branch.

              • @jjjalljs@ttrpg.network
                link
                fedilink
                21 year ago

                I don’t want to see a dozen commits of “ran isort” “forgot to commit this file lol” quality.

                Do you?

                Having the finished feature bundled into one commit is nice. I wouldn’t call it stupid at all.

                • Atemu
                  link
                  fedilink
                  11 year ago

                  Note that I didn’t say that you should never squash commits. You should do that but with the intention of producing a clearer history, not as a general rule eliminating any possibly useful history.

            • @cobra89@beehaw.org
              link
              fedilink
              11 year ago

              Lmao I’m in the NYC area and my whole house shook. I’m right there with you. Thanks for the explanation!

        • @GissaMittJobb@lemmy.ml
          link
          fedilink
          11 year ago

          You squash so all your gross “isort” “forgot to commit this file” “WIP but I’m getting lunch” commits can be cleaned up

          The next step on the Git-journey is to use interactive rebasing in order to never push these commits in the first place and maintain a clean history to be consumed by the code reviewer.

          Squashing is still nice in order to have a one-to-one relationship between commits on the main branch to pull requests merged, imo.

  • @jollyrogue@lemmy.ml
    link
    fedilink
    71 year ago

    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.

  • Zagorath
    link
    fedilink
    English
    251 year ago

    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?

  • 13
    link
    fedilink
    66
    edit-2
    1 year ago

    Imagine rewring history

    • Muad'Dibber
      link
      fedilink
      51 year ago

      You try to pull someone’s changes, but whoops, they used rebase and rewrote history! Delete the branch and start over.

      • @expr@programming.dev
        link
        fedilink
        3
        edit-2
        1 year ago

        2 things:

        1. You don’t pull rebased work pretty much ever. Rebasing is for feature branches by a single author to craft a high quality history, generally. It’s much, much better than littering your branch with merge commits from upstream.
        2. If for some reason you do need to pull rebased changes, you simply do git pull --rebase. Works without issue.
      • 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.

        • Muad'Dibber
          link
          fedilink
          41 year ago

          If you try to pull someone else’s rebased / history rewritten branch, your git will tell you that it’s rejected. You can completely avoid this by merging instead of rewriting history.

          • Atemu
            link
            fedilink
            11 year ago

            …or you simply rebase the subset of commits of your branch onto the rewritten branch. That’s like 10 simple button presses in magit.