• Ephera@lemmy.ml
      link
      fedilink
      arrow-up
      16
      ·
      3 months ago

      It does sometimes happen that something in there just breaks and isn’t easy to recover. But it can also be a matter of (inexperienced) devs just deciding, fuck it, I won’t try to merge it, I’ll just copy my changes elsewhere and throw away the repo.

      • nous@programming.dev
        link
        fedilink
        English
        arrow-up
        10
        arrow-down
        1
        ·
        3 months ago

        I have never had git get into a state I cannot get out of. Even if that is a reset, checkout or clean. And those are very rare. How are people breaking things so often.

        Learn the tools you use daily, it saves you a lot of headache in thelong term.

        • Ephera@lemmy.ml
          link
          fedilink
          arrow-up
          6
          ·
          3 months ago

          Oh yeah, but I’m talking about the internal Git state just genuinely being broken, for example: https://stackoverflow.com/questions/14448326/git-commit-stopped-working-error-building-trees
          Ultimately, if you spend half an hour debugging that, it just starts being a waste of time compared to cloning anew.

          As for how to merge, yes, one should learn that. The problem is that the complexity of the code changes adds on top of whatever insecurities you might still have with Git.
          I did put “inexperienced” in braces there, because even as an experienced dev, merges are sometimes just not worth doing. In that case, you could just checkout the branch a second time, but well, still not that different.

        • RobotZap10000@feddit.nl
          link
          fedilink
          arrow-up
          1
          ·
          3 months ago

          Step 1. Forget to push local commits

          Step 2. Push commits from another machine

          Step 3. Pull from remote om the first machine

          I’m a bit of a noob, I often do this when I get too careless.

          • nous@programming.dev
            link
            fedilink
            English
            arrow-up
            2
            ·
            3 months ago

            That should not break things though. Maybe get a merge conflict that you need to sortout at worst. This is essentially the constant state of working with other people on a project.

      • RecluseRamble@lemmy.dbzer0.com
        link
        fedilink
        arrow-up
        6
        ·
        3 months ago

        But it can also be a matter of (inexperienced) devs just deciding, fuck it, I won’t try to merge it, I’ll just copy my changes elsewhere and throw away the repo.

        Pretty sure that’s actually it. Git has a learning curve and, for example, some naive rebase not working out as intended can be scary if you don’t know what you’re doing.

    • PotatoesFall@discuss.tchncs.de
      link
      fedilink
      arrow-up
      9
      ·
      3 months ago

      People inexperienced with git can get stuck after doing some funky checkout / rebase stuff. If you don’t know your way around git so well, I guess this is the obvious solution.

    • SirQuackTheDuck@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      3 months ago

      I’ve been doing this yesterday. Not because Git broke, but since Intellij kept pulling invalid configs from the cache, and that was based on some kind of path identifier it seemed.

    • Johanno@feddit.org
      link
      fedilink
      arrow-up
      3
      ·
      3 months ago

      Gradle!

      Fucking gradle. I do config stuff, rerun gradle error here, I fix the error rerun gradle: sth. Violation error.

      Ok intellij invalidate chaches and restart… Still same error.

      Fine I’ll do it again

      git add. 
      git commit -m "stuff"
      git push
      
      rm -rf repo
      git clone repo
      
      • iammike@programming.dev
        link
        fedilink
        arrow-up
        4
        ·
        3 months ago

        You can probably use something like

        git clean -xdf
        

        To get rid of all the artifacts not tracked by git, in this case it’s virtually the same as deleting the repo and re-cloning it.

        NOTE: Make sure everyhing is staged, otherwise that data is gone