• lseif@sopuli.xyz
    link
    fedilink
    arrow-up
    51
    arrow-down
    3
    ·
    1 year ago

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

  • roastpotatothief@lemmy.ml
    link
    fedilink
    arrow-up
    14
    ·
    edit-2
    1 year 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 🐆@jlai.lu
      link
      fedilink
      arrow-up
      5
      ·
      1 year 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.

    • UNWILLING_PARTICIPANT@sh.itjust.works
      link
      fedilink
      arrow-up
      1
      ·
      1 year 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

  • erogenouswarzone@lemmy.ml
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    edit-2
    1 year 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.

    • Aniki 🌱🌿@lemm.ee
      link
      fedilink
      arrow-up
      1
      arrow-down
      3
      ·
      1 year ago

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

      you can always git fetch -a; git merge -X theirs remote-branch or rebase your branch.

      • erogenouswarzone@lemmy.ml
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year 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.

      • jjjalljs@ttrpg.network
        link
        fedilink
        arrow-up
        2
        ·
        1 year 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.

      • zalgotext@sh.itjust.works
        link
        fedilink
        arrow-up
        1
        ·
        1 year 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”.

  • lily33@lemm.ee
    link
    fedilink
    arrow-up
    6
    ·
    1 year ago

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

    • Kata1yst@kbin.social
      link
      fedilink
      arrow-up
      11
      ·
      1 year 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?’

      • zalgotext@sh.itjust.works
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        1 year 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@kbin.social
          link
          fedilink
          arrow-up
          6
          ·
          edit-2
          1 year 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.

    • jcg@halubilo.social
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      1 year 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!

  • dan@upvote.au
    link
    fedilink
    arrow-up
    8
    arrow-down
    5
    ·
    edit-2
    1 year ago

    Honestly, just use a GUI. Graphical user interfaces were designed for a reason. I usually use SourceTree or the Git functionality built in to Visual Studio or VS Code.

    It’s good to know how things work under-the-hood (e.g understand Git’s object model, some basic commands, etc) but don’t feel like you need to use the command-line for everything.

    • zalgotext@sh.itjust.works
      link
      fedilink
      arrow-up
      13
      ·
      1 year ago

      In my experience, using GUIs is how people fuck themselves, and then I have to unfuck them via the command line.

      Git’s interface is bad, yes. It has a step learning curve, yes. But I truly think the only real way to overcome those obstacles is to learn how git works, learn all the nitty gritty details, not hide from them.

      • CapeWearingAeroplane@sopuli.xyz
        link
        fedilink
        arrow-up
        4
        ·
        1 year ago

        I use a GUI (GitKraken) to easily visualise the different branches I’m working on, the state of my local vs. the remote etc. I sometimes use the gui to resolve merge conflicts. 99 % of my gut usage is command line based.

        GUI’s definitely have a space, but that space is specifically doing the thing the command line is bad at: Visualising stuff.

    • lseif@sopuli.xyz
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

      lazygit or tig are terminal interfaces for git. very nice, best of both worlds imo. every action shows the git command ran at the bottom, and its a lot easier to see at a glance the status, diff, log, etc.

      • lightnegative@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        1 year ago

        Do it enough times and it stops being scary.

        Using a tool like VSCode to perform the actual merges on individual files also helps because it shows what “yours” and “theirs” changes are from a user perspective, not a git perspective

    • space_comrade [he/him]@hexbear.net
      link
      fedilink
      English
      arrow-up
      12
      ·
      edit-2
      1 year ago

      It’s not THAT complicated but I wouldn’t call it dead simple. When you understand how git works internally yeah it’s pretty simple but people usually start with the idea that it’s a tool to put your code on a server to synchronize with other people and only later learn that you have both a local and a remote (or multiple remote) tree and how the tree really works.

      I think the problem is most git 101 tutorials teach it wrong, IMO the best git tutorial is this: https://wildlyinaccurate.com/a-hackers-guide-to-git/

      Unfortunately it’s pretty dense so it’s gonna scare off a lot of newbies.

    • oce 🐆@jlai.lu
      link
      fedilink
      arrow-up
      9
      ·
      edit-2
      1 year ago

      If it was dead simple you wouldn’t need to learn 10 new concepts and google commands regularly even after using it for a couple of years. You probably forgot how you struggled at first. I have taught it multiple times and I see how beginners struggle.