 Hello, my name is Morton and I used to pretend I understood Git. Turns out, I wasn't the only one. In fact, most people pretend to understand Git because Git is very, very confusing. And I realized after a while it's actually not confusing. It's not Git's fault. It's not our fault. It's not my fault. It's simply because we're thinking about it wrong. You see, Git is not a development tool. It's science fiction. So in this very short talk, I will explain Git to you in science fiction terms. Now to do this, I have to tell a story of Mike, a person who has to use Git to save herself. As all good stories, this one starts in space on a small ship with a very big problem. We have a gigantic oxygen leak. And to make matters worse, the jetpack is busted. So the air is leaking out, the single astronaut on board, Mike in, is royally screwed. She's screwed because if it was just the air leak, it would be fine. She could simply go outside, grab the patch kit on the outside of the ship, and just patch it. The problem is the jetpack is busted and she needs the patch kit to be on the inside of the ship. And she can't really go outside the ship without the jetpack on because that doesn't work. Now, of course, she could solve it if she had her cloning device with her, but that was left at home right before she went into space. So that doesn't work. The only thing she has is the Git console. But with the Git console, all things can be solved. So anytime you do anything, you always want to start by committing. Start 8, 1, 2, 0, 4, 2, 0, 15.2. I am royally screwed. When you make a commit, what you're doing is hitting the save button in a game or taking a picture of everything at its current place and time. And then you can always return to it. Once you've done that, you can create alternate timelines. So anytime you do something in life or in programming or anywhere else, you start by making an alternate timeline, you jump to that timeline and then you can start experimenting. So what do you do when your patch kit is on the outside of the ship, your suit is on the inside of the ship and busted and you need to do something while you go to the airlock and see what happens if you open it and you drift into space and turn it to space junk and whatever. So that didn't work, but that's not a problem because we are on an alternate timeline. So all you do is check out the original commit. Now you're back where we started. Simple. So we can start over and make a new timeline. Only this time, Mike takes a precaution. She ties herself to the bulkhead, then opens the airlock, lets the air escape, swings herself out the door, grabs the patch kit, stuffs it in the kangaroo purse on her suit and turns into space junk. But now the space junk has a patch kit. So everything is fine because when you're on an alternate timeline, you can always jump back to the original one and then merge the two together. As a result, Mike did not have a patch kit. The merge happens. Now she does. That means you can patch her jetpack, put on her spacesuit, create a new commit point, jump out into space, fly on over and grab the patch kit, which you never used in this timeline, go and create a new timeline and patch up the air leak. Only problem is the patch kit is not good enough. It only patches half of it, which is not a problem because she's on an alternate timeline, a branch. And whenever you're on a branch, you can always check back to the original timeline again. Then she can just merge the two together and now in her original timeline, she has a patch kit, a half-patched air leak and the ability to go back in time, grab the original patch kit again and patch the other half. Now if you're doing any kind of programming, this is usually where things go wrong. You've started working on a project, then you went, I need to do something else. You made another timeline or another branch. You messed around with it and you try to merge everything together. And then you get this nice little message saying, there's a conflict. And then you go, delete repository, download, start over. But you see, what's actually happening is Git is saying, hey, you're trying to do two things in the same place. It doesn't actually work. I'm not going to try to fix that for you. You have to fix it. So you have an overlap and all you have to do is jump into space, find the two patches that are overlapping and just edit one of them, make another commit, and everything is fine. The only problem is Mike is still in space and she kept opening the damn airlock so now she has no air. And when you have no air and you're on a spaceship, your friendly AI will tell you, are you sure you want to do that? Which is the best air message ever written, I think. The problem, of course, is she has a patched air supply but no air. But she also started the whole process by committing the starting point, which means you can just go back to the starting point where she has 70% air, recommit it in a new timeline, and rewrite history. If you go into Git and you create an alternate timeline or a branch and you rebase it, you are in fact applying something that happened in the past to the future. So she goes back in time, grabs air and puts it into the future. So using Git, she used one patched Git to fix three different problems and borrowed air from the past to save herself in the future. Like I said, science fiction explains this. Of course, you're all super confused right now. So here is Git in terms of science fiction. See, Git actually solves everything for us. First of all, Git is software, runs on your computer. Git Hub is where you store that software in the cloud so other people can collaborate to that software. A repository is your universe. That's where everything lives for your project. Git commit is the save points that you create as you work forward. Any commit you make, you can always return to at any time and you are literally resetting the universe to that state. Git branch is an alternate timeline. Once you create branches, you can jump to any branch at any time and any commit within that branch at any time and you can make as many as you want. Git checkout is a time machine. It allows you to jump between the branches and it allows you to jump between the commit points. Merge is when you take two timelines and merge them together. If you ever watched space, like what is it called? The supernova, the worst science fiction movie ever made. No one has watched it here. That's good. If you ever watched it, you'll understand why that's relevant. A conflict is when you make a change in the same place in two timelines and try to merge them together and to resolve a conflict, all you have to do is just go and fix it yourself. Rebase is literally rewriting history. You take one timeline and you stick it on top of another one as if that was always where it was. A fork is when you take one universe and create another universe that's an exact copy, whereas a clone is if you create an empty universe and then clone the content from one universe into that one. A push is if you take the contents of one timeline and stick it onto another timeline. A fetch is if you grab the content from one timeline and pull it into yours without merging it. A pull is if you do the same thing but you actually merge it to your timeline and the error everyone runs into. Detached head, the end of all attempts at using git. All that's happening here is you made a change and then jump back in time and you didn't save the change first. And to fix it, all you have to do is create a new branch and it automatically catches itself. Now, the last thing I'll say is this. If you've ever tried to use git, you likely started on a command line and that was likely the end of your attempt. So don't let that command line deter you because there are better options. Right now, we have two. GitHub desktop, with just everything for you and links to GitHub, and source tree, which is the same thing, but also links to Bitbuck. So as you can see, if you think in science fiction terms, git makes sense. Now that you've seen this, you wish you could go back in time to go like, oh, now I understand. I want to see that story one more time. Good for you. I checked out my timeline before I came here and if you go to my blog at Morton.com, you can see the annotated version of this entire talk right now if you check it out. Thank you very much.