• aport
    arrow-up
    42
    arrow-down
    3
    ·
    6 months ago
    link
    fedilink

    Reminder to read the official git book. It’s free and it’s useful. My dudes, stop pretending to understand your tools and actually learn them.

  • saigot
    arrow-up
    24
    arrow-down
    0
    ·
    6 months ago
    link
    fedilink

    I like this graphic, some of my favourites:

    git log --oneline is super useful for getting just a list of title of commits and nothing else

    git bisect is a little known but extremely useful git archaeology command that automates binary searching for a regression.

    • caseyweederman
      arrow-up
      7
      arrow-down
      0
      ·
      6 months ago
      link
      fedilink

      I just learned git bisect from https://ohmygit.org/! You run it, then checkout other commits all over the project, and mark them with git bisect good or git bisect bad. Then it paints all commits that led to the good one as good, and all the ones after the bad one as bad, so you just keep narrowing your window by playing checkout Jezzball until there’s only one commit left: the one that introduced the bad state.

      • catloafEnglish
        arrow-up
        14
        arrow-down
        0
        ·
        6 months ago
        link
        fedilink

        The technical term is binary search.

        • caseyweederman
          arrow-up
          1
          arrow-down
          0
          ·
          6 months ago
          link
          fedilink

          Yeah but I didn’t know that term until I looked it up. Also OhMyGit didn’t cover using tests and automating it.

          • huginn
            arrow-up
            2
            arrow-down
            0
            ·
            6 months ago
            link
            fedilink

            Definitely a useful tool and one you should’ve learned in a college algorithms course. Binary search backs a lot of high performance data structures

    • fmstratEnglish
      arrow-up
      7
      arrow-down
      0
      ·
      6 months ago
      link
      fedilink

      You’re gonna love this then:

      alias gl='git log --graph --abbrev-commit --no-decorate --date=format:'\''%Y-%m-%d %H:%M:%S'\'' --format=format:'\''%C(8)%>|(16)%h  %C(7)%ad  %C(8)%<(16,trunc)%an  %C(auto)%d %>|(1)%s'\'' --all'
      

      I have a whole rc file full of shortcuts like this for Git and Docker.

      • lars
        arrow-up
        3
        arrow-down
        0
        ·
        6 months ago
        edit-2
        6 months ago
        link
        fedilink

        Nobody loves pedantic escaped single quoting more than I.

        Except for you wow.

        Show us the rc.

  • stepanzak
    arrow-up
    18
    arrow-down
    0
    ·
    6 months ago
    link
    fedilink

    Great cheat sheet, but has a really poor quality, even when I download it. It may be problem on my side. The original on mastonon has good image quality.

    • very_well_lostEnglish
      arrow-up
      11
      arrow-down
      1
      ·
      6 months ago
      link
      fedilink

      More like “don’t fuck around but find out anyway”.

      • NegativeLookBehindEnglish
        arrow-up
        15
        arrow-down
        0
        ·
        6 months ago
        link
        fedilink

        “Fuck around, have no idea HOW you fucked around, fuck around some more trying to fix it, find out how badly you’ve collectively fucked around”

        • Alex
          arrow-up
          3
          arrow-down
          0
          ·
          6 months ago
          link
          fedilink

          That’s what the reflog is for!

      • lars
        arrow-up
        1
        arrow-down
        0
        ·
        6 months ago
        link
        fedilink

        More like “don’t fuck around (but of course the answer is some subset of git checkout (which is probably Turing-fucking-complete)), and find out anyway”.

      • xthexder
        arrow-up
        1
        arrow-down
        0
        ·
        6 months ago
        edit-2
        6 months ago
        link
        fedilink

        Unless you’re rebasing or something, you should never need --force. It’s a good way to accidentally delete or overwrite a remote branch.

        I usually use the +syntax for force-pushing a specific branch: git push origin +my_branch

  • boredsquirrel
    arrow-up
    8
    arrow-down
    0
    ·
    6 months ago
    link
    fedilink

    The only stuff I need, that should be easier

    • commit all changes
    • commit to other branch
    • squash all commits to one
    • configure a ssh key per user (especially when using different accounts, different username etc)
    • catloafEnglish
      arrow-up
      6
      arrow-down
      0
      ·
      6 months ago
      link
      fedilink

      Commit -a isn’t easy?

      Squashing is easy too, though no, there isn’t a “squash all” option, unless you’re working in a feature branch and check out master and git merge --squash branch: https://graphite.dev/guides/git-merge-squash

      I’m sure there’s a way to commit to another branch without having it checked out, but that just sounds like a recipe for trouble.

      And I have no idea how you’d manage to not have different ssh keys per user. You shouldn’t be reusing keys across accounts to begin with.

    • atzanteolEnglish
      arrow-up
      2
      arrow-down
      0
      ·
      6 months ago
      link
      fedilink

      commit to other branch

      ‘cherrypick’

  • ulternoEnglish
    arrow-up
    7
    arrow-down
    0
    ·
    6 months ago
    link
    fedilink

    Is there anyone other than me who read reflog as re-flog the first time?

      • ulternoEnglish
        arrow-up
        1
        arrow-down
        0
        ·
        6 months ago
        link
        fedilink

        Always need to remind myself that git doesn’t go around flogging anyone.

        • model_tar_gz
          arrow-up
          4
          arrow-down
          0
          ·
          6 months ago
          link
          fedilink

          Some people use git to flog, though. See

          git blame
          
  • beeng
    arrow-up
    4
    arrow-down
    0
    ·
    6 months ago
    link
    fedilink

    LazyGit

    For the lazy

    • Fedop
      arrow-up
      1
      arrow-down
      0
      ·
      6 months ago
      link
      fedilink

      Love lazygit, am I better or worse a git now? Idk but I’m doing it much faster

  • Valmond
    arrow-up
    1
    arrow-down
    0
    ·
    6 months ago
    edit-2
    6 months ago
    link
    fedilink

    I always forget how to do the delete distant branch with the : IIRC.