• @[email protected]
    link
    fedilink
    7111 months ago

    if u ever get a tricky merge conflict, just git push --force. this automatically works out the right code to keep (your own)

      • @Nahdahar
        link
        811 months ago

        Except if you’re an employer in a very small company.

        Source: my boss did this at the first company I worked at.

  • katy ✨
    link
    fedilink
    3611 months ago

    lemme rebase the main branch onto my branch.

    two minutes later

    1 merge conflict of 57 [abort] [continue]

    • @affiliate
      link
      1311 months ago

      this is easily fixed by copy pasting the files into a new directory and never opening git again out of fear

    • kamen
      link
      711 months ago

      One key thing that can help you wrap your head around rebasing is that branches get switched while you’re doing it; so, say you’re on branch feature and do git rebase master, for any merge conflict, whatever’s marked “current” will be on master and what’s “incoming” is from feature.

      There’s also git rerere that should in theory remember a resolution you do between two branches and reuse it every time after the first; I’ve rarely used it in practice; it would happen for long lived branches that don’t get merged.

  • stilgar [he/him]
    link
    fedilink
    English
    2811 months ago

    Pro tip: If your code gets flogged by git, you can always get revenge with git reflog 😉

  • @[email protected]
    link
    fedilink
    2411 months ago

    Learning git is very easy. For example, to do it on Debain, one simply needs to run, sudo apt install lazygit

    • Kata1yst
      link
      fedilink
      2411 months ago

      LazyGit may actually be black magic from Satan to tempt programmers into sin. And to that I say: ‘where is a goat I can sacrifice to my dark lord?’

    • Bipta
      link
      fedilink
      311 months ago

      Wow this looks great. Amend an old commit dealing with a rebase? Sign me up!

      • @[email protected]
        link
        fedilink
        5
        edit-2
        11 months ago

        git rebase -i origin/main (or whatever branch you’re rebasing on), then read the instructions that come up in the editor window

        • corytheboyd
          link
          fedilink
          10
          edit-2
          11 months ago

          Read… instructions? I love teaching people that git very often prints out what you should do next.

          git: “to continue, resolve conflicts, add files, and run rebase —continue”
          dev: …time to search stack overflow

          All that said… just use lazygit. It does help to know CLI git first to put things in context, but if you do, no need to punish yourself every day by not using a UI.

    • @[email protected]
      link
      fedilink
      1
      edit-2
      11 months ago

      I’d still probably prefer the usual CLI for setup, commits, pushes etc. but this looks like a godsend for any branching/rebasing operations!

      • @[email protected]
        link
        fedilink
        1
        edit-2
        11 months ago

        The ease with which I can only commit separate hunks with lazygit has ensured I use it for commits, too. And once I’ve opened it to do the commit, I may as well also press P.

        • Alex
          link
          fedilink
          111 months ago

          Is this what people who haven’t been introduced to #magit use?

          • @[email protected]
            link
            fedilink
            111 months ago

            Never tried magit, but it doesn’t matter. It couldn’t possibly be good enough to be worth using an inferior editor.

  • @[email protected]
    link
    fedilink
    18
    edit-2
    11 months ago

    Git is a great invention but it has a few design flaws. There are too many ways to confuse it or break it, using commands that look correct, or just forgetting something. I ended up writing simple wrapper script codebase to fix it. Since then no problems.

    • oce 🐆
      link
      fedilink
      1511 months ago

      It was conceived for experts so the new user experience is shit and the UI is not intuitive. But it has become such a widespread standard that it is very hard to completely overhaul the UI.

      • @sheogorath
        link
        911 months ago

        TBH compared to the old versioning system people used to use like SVN and Mercurial. Git is a godsend. Just taking your time in learning and not using a GUI client works wonders in learning how it works. Especially when all the GUI clients are basically a collection of commands being executed so if you fuck things up on CLI you know what happened vs using GUI.

      • Pxtl
        link
        fedilink
        English
        311 months ago

        Even for experts the user experience is shit. Too much has to be done manually when the default should be automatic, like fetching before pull, recursing when working with repos that use submodules, allowing mismatched casing on case insensitive filesystems, etc.

        • oce 🐆
          link
          fedilink
          211 months ago

          Submodule commands are such mess, which is sad because it is a great feature.

      • @[email protected]
        link
        fedilink
        111 months ago

        Yes you couldn’t change something so widely used. Look what happened with python 3.

        Fortunately there’s already a tradition among Git users of building a UI on top of the git UI. My project is just a slightly better version of those. It lays a simple sensible interface on top of the chaotic Git interface.

  • @Skullgrid
    link
    1211 months ago

    …not by choice, because if I don’t I’ll lose my job

    • @[email protected]
      link
      fedilink
      111 months ago

      This is great, but I just want to say that the best way to use git is to simply stop doing so much in one branch. Branches should not last longer than a week, ideally

  • @[email protected]
    link
    fedilink
    English
    9
    edit-2
    11 months ago

    Great meme, and I’m sure op knows this, but for anyone else who is curious…

    007 in theory means:

    • 00: you have already committed your code to your local code base
    • 7: When you try to merge your code with everyone else’s there are 7 files that others have worked on since you last refreshed your local code base.

    To resolve this, you need to go file by file and compare your changes with the changes on the remote code. You need to keep the changes others have made and incorporate your own.

    You can use git diff file_name to see the differences.

    If you have made small changes, it’s easier to pull and force an overwrite of your local code and make changes again.

    However multiple people working on the same files is usually a sign of organizational issues with management. Ie, typically you don’t want multiple people working on the same files at the same time, to avoid stuff like this.

    If you’re not sure, ask someone that knows what they’re doing before you follow any advice on Lemmy.

      • @[email protected]
        link
        fedilink
        411 months ago

        If I get a big conflict and I know my change is trivial, I feel perfectly okay doing git fetch git reset --hard whatever and then reapplying my simple change as a new commit. Sort of a bootleg rebate.

      • @[email protected]
        link
        fedilink
        English
        211 months ago

        I hear what you’re saying.

        First, I hard disagree with you. Overwriting my local version of code is a parachute - not an ideal landing, but better than merging by hand.

        Also, my comment was not an attempt to teach everything about git, just to explain what is happening in simple terms, since git requires a lot of experience to understand what those messages mean.

      • @[email protected]
        link
        fedilink
        111 months ago

        If you use a squash workflow, you’re going to be force pushing a ton.

        Never force git to do anything. If you’re forcing something you’re doing it wrong.

        This is bad advice. Better advice would be “know and understand your tool, and know the consequences of your actions”.

  • Haus
    link
    fedilink
    611 months ago

    sccs, rcs, cvs… after that it’s a blur of new systems every year or two

    • @kautau
      link
      13
      edit-2
      11 months ago

      sccs

      1973

      rcs

      1982

      git

      2005

      How long are your years?

    • pelya
      link
      311 months ago

      Subversion is as good as it can get with centralized version control system.

      CVS is only one step up above FTP file server for all your code.