• expr@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    3 months ago

    Yeah it is something people should take time to learn. I do think its “dangers” are pretty overstated, though, especially if you always do git rebase --interactive, since if anything goes wrong, you can easily get out with git rebase --abort.

    In general there’s a pretty weird fear that you can fuck up git to the point at which you can’t recover. Basically the only time that’s really actually true is if you somehow lose uncommitted work in your working tree. But if you’ve actually committed everything (and you should always commit everything before trying any destructive operations), you can pretty much always get back to where you were. Commits are never actually lost.

    • ipkpjersi@lemmy.ml
      link
      fedilink
      arrow-up
      4
      ·
      3 months ago

      True, the real danger is using git reset with the --hard flag when you haven’t committed your changes lol

    • thanks_shakey_snake@lemmy.ca
      link
      fedilink
      arrow-up
      0
      ·
      3 months ago

      You can get in some pretty serious messes, though. Any workflow that involves force-pushing or rebasing has the potential for data loss… Either in a literally destructive way, or in a “Seriously my keys must be somewhere but I have no idea where” kind of way.

      When most people talk about rebase (for example) being reversible, what they’re usually saying is “you can always reverse the operation in the reflog.” Well yes, but the reflog is local, so if Alice messes something up with her rebase-force-push and realizes she destroyed some of Bob’s changes, Alice can’t recover Bob’s changes from her machine-- She needs to collaborate with Bob to recover them.

      • expr@programming.dev
        link
        fedilink
        arrow-up
        0
        ·
        3 months ago

        Pretty much everything that can act as a git remote (GitHub, gitlab, etc.) records the activity on a branch and makes it easy to see what the commit sha was before a force push.

        But it’s a pretty moot point since no one that argues in favor of rebasing is suggesting you use it on shared branches. That’s not what it’s for. It’s for your own feature branches as you work, in which case there is indeed very little risk of any kind of loss.

        • aubeynarf@lemmynsfw.com
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          2 months ago

          If “we work in a way that only one person can commit to a feature”, you may be missing the point of collaborative distributed development.