Yeah learned this the hard way.

  • LedgeDrop@lemmy.zip
    link
    fedilink
    arrow-up
    11
    arrow-down
    5
    ·
    1 day ago

    … and force push.

    If you ever find yourself in a situation where rebase or a force push seems to be the solution, take a step back, clone your repo in a new directory and copy the changes into you’re new checkout - ‘cause you gon’ and screwed somethin’ up, son.

    • witness_me@lemmy.ml
      link
      fedilink
      arrow-up
      20
      ·
      1 day ago

      I rebase and force push daily. I like squashing all my commits, and our main branch moves quickly so I rebase off that often. Zero issues for me.

      • smiletolerantly@awful.systems
        link
        fedilink
        arrow-up
        8
        ·
        1 day ago

        Same. And even if you were to fuck up, have people never heard of the reflog…?

        Every job I’ve worked at it’s been the expectation to regularly rebase your feature branch on main, to squash your commits (and then force push, obv), and for most projects to do rebase-merges of PRs rather than creating merge commits. Even the, uh, less gifted developers never had an issue with this.

        I think people just hear the meme about git being hard somewhere and then use that as an excuse to never learn.

      • hayvan@feddit.nl
        link
        fedilink
        arrow-up
        2
        ·
        1 day ago

        Yeah, I hate it when my repo is a chain of merge commits. I want to see actual changes to the code, not branch management history.

        • Mr. Satan@lemmy.zip
          link
          fedilink
          arrow-up
          2
          ·
          1 day ago

          I’m the opposite. I just let git take care of the stupid content. Why mess with the commit graph? Merging locally (instead of squashing) works better with merge requests because the graph clearly shows what changes went where.

          I do some branch maintenance on my local branch (rebasing) until there are conflicts, but other than that I don’t see any benefit for messing with commit history.

    • majster@lemmy.zip
      link
      fedilink
      English
      arrow-up
      8
      ·
      1 day ago

      I rebase and force push PR branches all the time. Master is moving quicker than my PR.

      • SavinDWhales@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        1 day ago

        Yeah, our whole workflow is based on rebasing our feature branches on develop. Makes for a clean git log. :)

        Don’t be afraid of git reset --hard if you rebased with the button on GitHub/gitlab, though. :D

    • GissaMittJobb@lemmy.ml
      link
      fedilink
      arrow-up
      4
      ·
      1 day ago

      Force pushing is necessary when using rebases, and rebases are an essential tool, so you should not be afraid to force push under normal circumstances.

    • killeronthecorner@lemmy.world
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 day ago

      A few days ago I had to gently explain to someone why their rebase-and-force-push strategy not only prevented the use of “review latest” feature on GitHub, but was also pointless because all PRs are squash committed to main.

      They didn’t get it and now they seem a little mad at me.

      • GissaMittJobb@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        1 day ago

        I’m guessing this is in reference to a scenario where a review of the PR has already been performed, and the rebase+force push is made to introduce new changes to the PR, possibly to address PR feedback.

        I agree that these changes should be made in separate commits, for the benefit of the reviewer.

        There are other scenarios where rebases are appropriate though, such as getting potentially incompatible changes from the main branch into the PR, and here I believe a rebase+force push is the right tool for the job.

        • killeronthecorner@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          edit-2
          1 day ago

          Oh there’s totally a time and place for rebase strategies, this just wasn’t one of them.

          Git’s biggest problems come from
          people taking ritualistic views on what is “right” instead of thinking about which strategies work best for the situation, project, and team.