We all have been there… For the beginner it’s easy to mess things up. What are your horror stories with Git?

Link to xkcd

  • unknowing8343@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Those first couple months learning git… yeah, it is weird, but once it clicks… you’ll be surprised how truly simple it is.

    The programming world would be awful without it

  • HunterBidensLapDog@infosec.pub
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    As an old programmer who has used git since Linus whipped it up over one frenzied weekend after his spat with the evil BitKeeper and who has studied its mysteries since before most of you were born … yeah just delete the damn project and download a new version.

  • qwop@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    I’ve often ended up guessing what things do and messing things up.

    One example is when I couldn’t remember the difference between git checkout -b and git checkout -B, so in my infinite wisdom I decided to use -B because surely capital letters are better! Tried using it to switch back to a branch, and… Yeah, that was annoying.

  • cliffhanger407@programming.dev
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Joined on a project and the unsupervised junior devs had branches for each developer, even if they were working on the same features. They were copying and pasting each others code into their personal branches to stay up to date.

    Spaghetti commits took a while to unwind.

  • letsgo@lemm.ee
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Not really a horror story because I fixed it with reflog, but it was a bit of a shock when we all suddenly couldn’t push to the dev branch. Turns out one of the devs, who insists Git is just like SVN, decided to delete dev and push, and ignore the warnings. Apparently that’s OK in SVN.

  • JackbyDev@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    1 year ago

    Alright, currently dealing with a CRLF issue from hell. The .gitattributes file says bat files should have CRLF endings but some template we use with backstage and cookiecutter makes the gradlew.bat file end up with CRLF line endings in the repository. Quick aside, whenever git is handling line ending conversions it sotres LF line endings inside the blobs then makes them CRLF on checkout. In the template repository everything is correct. But for some reason when you run the template the batch file has CRLF line endings in the repository.

    Why does this matter? Because you’ll have a totally fresh untouched repo and git will report a change in a file. You’llook at the doff and not see what is going on. Because you made no change. But git is trying to fix the problem of CRLF being in the repo when the attributes file says it needs to control the line endings.

    You have to use the git cat-file command to see what is in the blob.

    Yesterday I thought I narrowed it down to the Node project isomorphic-git but it actually seems to handle it correctly but I’m still suspicious.

    Any advice is appreciated lol

    • whats_all_this_then@programming.dev
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      1 year ago

      I’ve had a similar issue before and the problem was that I had made the repo on linux, worked on it a bunch, copied it over to a different PC running windows, then copied it back. Found this on stackoverflow and it fixed it for me, but I’ve only tested it on linux (probably won’t work on windows because grep). Hopefully it helps:

      git diff -p -R --no-ext-diff --no-color | grep -E \"^(diff|(old|new) mode)\" --color=never | git apply

      • JackbyDev@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

        That’s the weird thing, everyone here uses Mac and the server running the template is Linux so this isn’t a case of a Windows user forgetting to set autocrlf and even then it is in the git attributes file.