Sky-Lemmy
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
lemmyreader@lemmy.ml to Linux@lemmy.mlEnglish ·
edit-2
1 year ago

a git cheat sheet - Julia Evans

cdn.masto.host

message-square
37
fedilink
  • cross-posted to:
  • opensource@lemmy.ml
494

a git cheat sheet - Julia Evans

cdn.masto.host

lemmyreader@lemmy.ml to Linux@lemmy.mlEnglish ·
edit-2
1 year ago
message-square
37
fedilink
  • cross-posted to:
  • opensource@lemmy.ml

cross-posted from: https://lemmy.ml/post/14581344

https://social.jvns.ca/@b0rk/112288027169476498

alert-triangle
You must log in or register to comment.
  • aport@programming.dev
    link
    fedilink
    arrow-up
    42
    arrow-down
    3
    ·
    1 year ago

    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.

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

      https://git-scm.com/book/en/v2

    • The Doctor@beehaw.org
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      Madness!

  • ulterno@lemmy.kde.social
    link
    fedilink
    English
    arrow-up
    31
    ·
    1 year ago

    For those who like what I like

    • lemmyreader@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      1 year ago

      Looking great. Thanks.

  • saigot@lemmy.ca
    link
    fedilink
    arrow-up
    24
    ·
    1 year ago

    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.

    • fmstrat@lemmy.nowsci.com
      link
      fedilink
      English
      arrow-up
      7
      ·
      1 year ago

      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@lemmy.sdf.org
        link
        fedilink
        arrow-up
        3
        ·
        edit-2
        1 year ago

        Nobody loves pedantic escaped single quoting more than I.

        Except for you wow.

        Show us the rc.

    • caseyweederman@lemmy.ca
      link
      fedilink
      arrow-up
      7
      ·
      1 year ago

      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.

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

        The technical term is binary search.

        • caseyweederman@lemmy.ca
          link
          fedilink
          arrow-up
          1
          ·
          1 year ago

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

          • huginn@feddit.it
            link
            fedilink
            arrow-up
            2
            ·
            1 year ago

            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

  • stepanzak@iusearchlinux.fyi
    link
    fedilink
    arrow-up
    18
    ·
    1 year ago

    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.

    • lemmyreader@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      6
      ·
      1 year ago

      I’ve edited this post and linked to the original on Mastodon.

      • saigot@lemmy.ca
        link
        fedilink
        arrow-up
        2
        ·
        1 year ago

        ccan you link the higher wuality one here in a comment, I don’t think It’s propagated.

        • lemmyreader@lemmy.mlOP
          link
          fedilink
          English
          arrow-up
          5
          ·
          1 year ago

          https://cdn.masto.host/socialjvnsca/media_attachments/files/112/288/026/870/908/533/small/8cdf198fa52700f6.png

          • moe93@lemmy.ml
            link
            fedilink
            arrow-up
            18
            ·
            edit-2
            1 year ago

            Still low quality.

            EDIT: here is a link to a higher resolution. Link

            • lemmyreader@lemmy.mlOP
              link
              fedilink
              English
              arrow-up
              6
              ·
              1 year ago

              Thanks!

    • blobjim [he/him]@hexbear.net
      link
      fedilink
      English
      arrow-up
      1
      arrow-down
      1
      ·
      1 year ago

      You have to expand the image to its full size. Thumbnail images are downscaled so they use less data.

  • NegativeLookBehind@lemmy.world
    link
    fedilink
    arrow-up
    15
    arrow-down
    1
    ·
    edit-2
    2 months ago

    deleted by creator

    • very_well_lost@lemmy.world
      link
      fedilink
      English
      arrow-up
      11
      arrow-down
      1
      ·
      1 year ago

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

      • NegativeLookBehind@lemmy.world
        link
        fedilink
        English
        arrow-up
        15
        ·
        edit-2
        2 months ago

        deleted by creator

        • Alex@lemmy.ml
          link
          fedilink
          arrow-up
          3
          ·
          1 year ago

          That’s what the reflog is for!

      • lars@lemmy.sdf.org
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        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”.

  • 𝘋𝘪𝘳𝘬@lemmy.ml
    link
    fedilink
    arrow-up
    14
    arrow-down
    1
    ·
    1 year ago

    tl;dr

    git add .
    git commit -a
    git push
    
    • Benaaasaaas@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      You dropped --force

      • xthexder@l.sw0.com
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        1 year ago

        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

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

          I thought -a is shorthand to amend my bad

  • boredsquirrel@slrpnk.net
    link
    fedilink
    arrow-up
    8
    ·
    1 year ago

    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)
    • catloaf@lemm.ee
      link
      fedilink
      English
      arrow-up
      6
      ·
      1 year ago

      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.

    • atzanteol@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      2
      ·
      1 year ago

      commit to other branch

      ‘cherrypick’

  • ulterno@lemmy.kde.social
    link
    fedilink
    English
    arrow-up
    7
    ·
    1 year ago

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

    • model_tar_gz@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Every time.

      • ulterno@lemmy.kde.social
        link
        fedilink
        English
        arrow-up
        1
        ·
        1 year ago

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

        • model_tar_gz@lemmy.world
          link
          fedilink
          arrow-up
          4
          ·
          1 year ago

          Some people use git to flog, though. See

          git blame
          
  • beeng@discuss.tchncs.de
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    LazyGit

    For the lazy…

    • Fedop@slrpnk.net
      link
      fedilink
      arrow-up
      1
      ·
      1 year ago

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

  • toastal@lemmy.ml
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 year ago

    Tangent are these VCS Rosetta Stones that might be interesting to some:

    • Darcs/Git/Mercurial: https://darcs.net/RosettaStone

    • Pijul/Git: https://nest.pijul.com/tae/pijul-for-git-users

  • Valmond@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    1 year ago

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

Linux@lemmy.ml

linux@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !linux@lemmy.ml

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

  • !opensource@lemmy.ml
  • !libre_culture@lemmy.ml
  • !technology@lemmy.ml
  • !libre_hardware@lemmy.ml

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 455 users / day
  • 165 users / week
  • 4.14K users / month
  • 16.3K users / 6 months
  • 0 local subscribers
  • 53.2K subscribers
  • 7.29K Posts
  • 192K Comments
  • Modlog
  • mods:
  • nooter692@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • MarcellusDrum@lemmy.ml
  • Arthur Besse@lemmy.ml
  • Cyclohexane@lemmy.ml
  • d3Xt3r@lemmy.nz
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org