Interactive Git Cheatsheet


179 points | by taatparya 221 days ago


  • jasode 221 days ago

    I'm not criticizing the cheatsheet and can see how it can help but if I may point out 2 possible points of confusion for Git novices:

    If the conceptual boxes of "stash", "workspace",...,"upstream repo" represent a left-to-right timeline of workflow, having "stash" being on the left of "workspace" is somewhat misleading. A stash point-in-time usage can be thought of in the same vertical time-alignment as "index" or "local repository".

    If the conceptual boxes represent a storage model, then stash being a separate isolated box is somewhat misleading. The stashes are actually stored in the "local repository". (E.g. an alternative diagram would show "index" and "stash" as nested boxes inside of "local repository".)

    I readily admit that spatially rearranging how "stash" is diagrammed complicates the arrows illustrating the git commands. Therefore, maybe the way the cheatsheet did it is the best compromise.

    • epicide 221 days ago

      I understand why everyone wants git cheatsheets (there are a lot of commands), but I have yet to see a cheatsheet/etc that does little more than become a crutch.

      For better or for worse, git really demands that you learn the concepts and fundamentals. It has a steep learning curve, but it's one that easily pays dividends.

      Do I wish it were easier to learn? Of course.

      Can you substitute actually learning how git and its workflows are used with cheatsheets and quick primers? Not remotely.

      That being said, I think this one is a step in the right direction by being interactive. Something like a "git simulator" could be incredibly powerful in teaching people git.

      • ken 221 days ago

        I could replace "git" and "cheatsheet" with "Unix" and "GUI", or "ed" and "screen editor", or any number of other difficult tasks. Yet even the experts I know today don't use Unix without any GUI -- or line editors.

        I've been using git for almost 10 years now, and I've read the "concepts and fundamentals" many times, yet I still find these handy. I still google common git tasks, and take the first StackOverflow hit and paste it in my shell.

        Knowing the fundamentals doesn't make it any easier to memorize overly-complex sequences of steps. Or maybe it does, but it requires someone smarter than me, or twice as long as it took to get both my college degrees. At what point do we admit that something is just too complicated?

        Reading the Git fundamentals is like learning Maxwell's Equations. Great, you know the fundamentals. That doesn't make it easy to complete any possible task using them. I'm still going to use a cheat sheet (like Ohm's Law!) when I can, rather than deriving everything from fundamentals each time.

        • epicide 221 days ago

          I completely agree with you.

          I think my original wording came off as more harsh than I intended. I was definitely thinking about cheatsheets solely in the context of handing them off to beginners (I am biased towards this since I end up teaching git to a lot of people as part of my job).

          Using cheatsheets as cheatsheets, as you describe, is totally fitting. I just often see them either getting handed to beginners as "here you can learn git real quick with this" or intermediate users relying on them to look up things that they should probably have committed to memory by now (a good example escapes me, unfortunately).

        • kstenerud 221 days ago

          The problem is that git has terrible U/X.

          The commands are unintuitive, have defaults that nobody uses, and use names that are prone to misinterpretation because they have completely different meanings from what you'd expect.

          It's not only difficult to learn; it's difficult to remember the commands and the switches you have to add every single time (why?), and all the extra commands you have to throw in just to get from a checkout to a complete working tree.

          Git's UI really needs an overhaul. Unfortunately, I fear it is already too late.

          • da_chicken 221 days ago

            This is it exactly.

            I'm really kind of tired of the "git demands you understand the concepts and the model" excuse because that really isn't what's going on. It's just a poor interface with an un-intuitive set of commands that are organized according to what makes sense to the person who developed the software rather than what makes sense to a person using the software.

            Lots of systems demand that you learn the underlying concepts and structures. Indeed, nearly all computer systems demand that when you get to a developer, operations, or admin level. It's actually kind of condescending to keep seeing people repeating that over and over. It's not difficult to understand that git is basically a repository of a repository. If you already understand branching and merging from SVN, it's easy to explain git with a single image[0]. It's still difficult to learn to use git and absolutely nothing about the software eases that transition. Claiming the problem must be with the user and their inability to learn the system should clearly have been incorrect somewhere around 8 years ago when people were still struggling to learn it after it had been out for 5 years.

            I imagine some day we'll run into a situation that's similar to apt vs apt-get vs aptitude where there are multiple clients that do the same thing, but it's not clear to me if someone will just create a better product before that time comes along (that product is probably the GitHub client).


            • epicide 221 days ago

              > Claiming the problem must be with the user and their inability to learn the system

              Please do not put words in my mouth.

              I agree that the interface could be a lot better and honestly hope it improves. I do not expect this to happen anytime soon so I work with what I've got.

              That being said, the problems git solves in the way that it does so are tricky to wrap your head around. This is why I push people to learn the concepts, not because I think people are stupid for not committing (heh) a bunch of arbitrary commands to memory.

              The fact that the interface is so unintuitive is exactly why I like to promote learning the concepts instead of just the commands.

              Once you understand the concepts (with or without knowing any of the commands), not only is it sometimes easier to remember the commands, it makes things like cheatsheets useful.

              > Indeed, nearly all computer systems demand that when you get to a developer, operations, or admin level. It's actually kind of condescending to keep seeing people repeating that over and over.

              Some people, for whatever reason, just don't treat git this way. I've seen plenty of people treat it like they treat tar or some other tool where they just remember a bucket of commands and wonder why nothing ever works.

              If it's obvious to you, then I apologize for it sounding condescending, but it's just not obvious to everyone.

              • massaman_yams 221 days ago

                Another comparison: iptables with its hard-to-remember syntax, vs ufw.

                As UFW is just a wrapper for iptables, I wonder if there's a real possibly of a Git replacement just being a wrapper that simplifies the syntax and maybe some of the conceptual model.

            • octosphere 221 days ago

              > The problem is that git has terrible U/X.

              I know this pain. Trying to debug a merge conflict for the first time is like trying to do open heart surgery with no prior training.

            • Analemma_ 221 days ago

              Even once you learn git's fundamentals, the UI still sucks though. I like to think I have a pretty good grasp on the git model, but I still consider this article an absolute must for git use:

              Whenever I use a computer and I don't have "git unstage", "git discard", "git publish", etc. it feels like I've lost my opposable thumbs

              • brantonb 221 days ago

                Here is a git simulator that GitHub consulting uses in their courses. I particularly like the “Free Explore with Remote” mode.


                • epicide 221 days ago

                  This is close to what I'm wanting. The problem with this is that it doesn't have anywhere near enough supported commands. Even just basic ones like "git add" don't seem to be included.

                  I think that just makes things even more confusing for absolute beginners, but could be useful for advanced beginners and intermediate git learners.

                  EDIT: I'm realizing this tool will be perfect for creating instructional materials.

                • jacobsenscott 221 days ago

                  This is actually a good learning tool, and not just a cheatsheet. Understanding how the data moves around the different parts of the git repository is half the battle.

                  • epicide 221 days ago

                    Like I said, I think it's a step in the right direction. It provides a bit more guidance than a typical cheatsheet, but I'd still consider it mainly a cheatsheet.

                    It doesn't really show how data moves around the different parts as much as it hints that something moves into these nebulous buckets when you run certain commands.

                  • invalidusernam3 221 days ago

                    Git gets complex pretty fast, but in teaching the junior devs starting at my company I realized there are really only 5 or so commands that get used on a daily basis for the basic stuff: fetch, checkout, add, commit, push

                    I think if people new to git can wrap their heads around those, the rest is easier to learn and can be learnt as needed

                • stblack 221 days ago

                  This cheatsheet has been around for years. Nothing has helped me grok git better than this cheatsheet.

                  Here is its Github repo:

                • berti 221 days ago

                  I think they've been HN'ed. I'm guessing a stylesheet failed altogether in my browser because it's unreadable.

                  wget 0.05s user 0.01s system 0% cpu 51.874 total

                  • modzu 221 days ago
                    • brokenwren 221 days ago

                      Am I missing something or is there no `git push`?

                      • niel 221 days ago

                        Push takes place between your local and remote repo. When you click on either, you'll see remote/local repo commands, including push.

                        • ranie93 221 days ago

                          Click on the "Local Repository" column

                          • brokenwren 221 days ago

                            Ahhhh. I had no idea this thing was interactive. That's not intuitive at all. The only that that indicates that is the "Interaction" in the title and I skipped over that part and just start reading the commands.

                          • 221 days ago
                          • npalmer 221 days ago

                            Looks like the site is struggling at the moment, cached version here:

                            • m4r35n357 221 days ago

                              Looks like that is down too now . . .

                            • esaym 221 days ago

                              I only recently started using 'git stash', thanks to this quick script:

                              • 221 days ago
                                • modzu 221 days ago

                                  nobody has mentioned the other popular cheatsheet called github desktop?

                                  • sabujp 221 days ago

                                    it's missing git fetch and bunch of other stuff

                                    • niel 221 days ago

                                      I've mentioned this on another comment. Click on either "Local Repository" or "Upstream Repository" to see the repo-related commands.

                                      Edit: Had "Remote Repository" instead of "Upstream Repository".

                                      • 221 days ago
                                        • frant-hartm 221 days ago

                                          git fetch is right there between local and upstream repository.

                                        • ArtemZ 221 days ago

                                          This cheatsheet has almost as bad UX the git itself