The Git version control system has become incredibly popular, with many people using it to collaborate on shared projects. John Albin Wilkins joins Jen Simmons to explain what Git is, how it works and how to use it.
Transcript
Thanks to Jason Neel for transcribing this episode.
Jen Simmons This is The Web Ahead, a weekly conversation about changing technologies and the future of The Web. Iâm your host Jen Simmons, and this is episode 40! I want to say thank you so much to todayâs sponsor, The In Control Conference, along with CSS Dev Conf. Weâll talk more about them later in the show. So, this week, this show got planned very last minute. Sometimes thereâs these gaps in the schedule, and I kind of like, I realized Iâve kind of like waiting and seeing what happens and seeing if thereâs something happening, some kind of neat suddenly popping up, discussions popping up on Twitter or online somewhere. And thatâs exactly what happened this week. I think it was three days ago, there was a bunch of tweets going around. Some of the people I follow, some really well-known, amazing designers â web designers â who were like, âUgh! Git! Ugh! I donât quite understand Git! Git drives me crazy! Iâm so frustrated! Oh, Iâve been meaning to learn that!â And I thought thatâs a really good subject for The Web Ahead. Maybe we should do a show about Git and do a kind of practical show for people who maybe want to learn Git, or maybe know they should be using it, or they already are using it and theyâve looked at some tutorials but theyâre still kind of frustrated or they donât quite understand how it works. Sometimes I find thatâ Sometimes tutorials are very how-to â step 1, step 2, step 3 â but what makes sometimes this technology hard is not knowing a bigger picture, not quite understanding the mental model or the kind of the whatâs going on bigger than the, âOh! You should type git -m-â, you know, like that stuff is good but then if you donât quite ever piece together the mental model then sometimes that stuffâs hard. So, John Albin Wilkins is the guest today. He and I have worked together on quite a few projects and heâ I was asking and talking to a lot of people on Twitter about this. He raised his hand. I was like, âJohn would be great!â So, hello John!
John Albin Wilkins Hello!
Jen I was really glad that you volunteered to come on the show with me and talk about Git. John, for people who donât know, heâs a really kick-ass Drupal developer. He has maintained the Zen theme for many, many years. The Zen theme is kind of starter kit theme in the Drupal world that I highly recommend and love and recommend to people all the time. Heâs also the lead of the initiative to make Drupal 8 much more mobile-friendly and put a lot of mobile best practices in place. He co-authored the Drupal 7 Module Development book, and a bazillion other things. And youâre also about to start writing a book about Sass and Compass for OâReilly.
John Yes, I sure am. Yeah, like Iâm talking to theâ my future editor this week. And we sort of came to agreement this week. So, itâs like breaking news.
Jen Breaking news!
John Yes.
Jen I love breaking news.
John I hadnât told anybody until I told you.
Jen Yay! More new breaking news on The Web Ahead. Yeah, so I mean, Drupal Drupal Drupal. Thatâs how we know each other. And the Drupal community, in fact, switched from CVS to Git a number ofâ now maybe two years ago? So I feel like there was a lotâ There was a period there in the worlds that we live in, there was this big surge of discussion about Git and a lot of camps and tutorials and conference sessions to help teach people Git, and sort of this group effort to learn Git all at once. I feel likeâ At least thatâs how I learned Git, was in that period of time.
John Oh definitely. Before Drupal switched over to Git, they were using CVS, which is a really now painful to use version control system. But when we started using it 10 years ago, that was it. There was nothing else that you could use, so. And yeah, during that time, thatâs when everybody that I knew was learning Git and it wasâ There was a lot of people who didnât understand how the system worked, and I ended up teaching a lot of people how to use Git. There were a couple of conferences for Drupal, DrupalCons, where I just, like, taught people how to use Git, especially front-end developers and designers.
Jen Yeah, thereâs nothing likeâ Because, I mean, there was a period there where you could just go into IRC, into one of the Drupal chatrooms â and it really had nothing to do with Drupal; it just happened to be a community of people â and ask any dumb question you ever wanted to about Git. And thereâd be like six people who would be like, âHere! Iâll help you. Iâll walk you through thatâ, [laughs] which was really, really nice. So, Iâm hoping to kind of do some of that today on this podcast episode. Letâs, letâs just start with super basic: what in the world is version control and why in the world does somebody want to use it?
John Right. So, yeah I think it really is useful to look at sort of the history of version control a little bit, just so that you sort of build this mental model because Git is such a new, new way of doing things that trying to explain it without any sort of background of how the ways used to work, itâs very challenging. So, like, letâs go back to the very beginning. Original version control was basically Iâve got this file. Iâm working on it. I want to keep a copy of this current version, and I just, you know, go into the Finder and hit Duplicate, right? And now Iâve got the same filename that says space copy at the end. And then I edit the filename to add like a date, right? And thatâs version control. You just keep old copies of the file around.
Jen And a lot of people still do. I mean, thereâs probably plenty ofâ majority of people listening to the show right now who are like, âOh yeah! Iâve done that. I got Photoshop Awesome Design 1, Awesome Design 2, Awesome Design 3, Awesome Design 4, [laughs] Awesome Design FinalââŠ
John Yeah, and my favoriteâ Yes, Awesome Design Final 2.
Jen âŠFinal Final The Real Final. Yeah. I mean, that is version control. You are attempting to have multiple versionsâŠ
John Sure.
Jen âŠand control the situation. [laughs] You might not be succeeding in controlling it very well, but. Or maybe you are but itâs very manual. Itâs very human-created, the situation.
John Right. And sort of the next step beyond that wasâ There was a system called RCS that I used way back in the paleolithic era when I went to college. And it was a program that could help you make, you know, copies basically of yourâ backup copies of all of your files that you could later go back and sort of compare old versions to new versions and it would sort of do this transparently in that youâre editing a file and then you would tell RCS, âHey! Save a copy of thisâ, and it would go and it would make, you know, basically a new commit as they call it. But it would, you know, there would be no like cluttered file system with all these different copies of the same file. It would be sort of hidden inside the RCS repository. But it only worked on your computer. If you wanted to share your work with somebody, you were working with on a project together with somebody, it just didnât work. You basicallyâ You had to share the computer in order to share the repository, so umm.
Jen Yeah, and as a bit of a tangent, it almost seems like Time Machine is sort of doing something like that, where itâs in your own personal world.
John Mmm-hmm.
Jen If youâre using Time Machine, you know, your Apple operating system, Macintosh operating system is taking a snapshot of your computer every day and sort of keeping that so that if you realize when you open up your Excel spreadsheet on Tuesday that, âOh my gosh, whereâ I worked on this all last week and on Friday it was perfect and now itâs Tuesday and everythingâs missingâ. You can kind of open up Time Machine and go back in time and get the one from Friday before you accidentally erased everything, andâ So itâs a very different kind of thing than, you know, Git but itâs solving the same problem: the problem of, you know, we need to have some backups here. We need to have some ways to keep track of things. We need to make sure that if we make a mistake and accidentally delete everything, we can go back in time and we can get it back.
John Mmm-hmm. Yeah. And the only difference between Time Machine and a version control system is that usually in version control system you tell them explicitly, like, now is when I want to make a backup copy, right? Like, Iâve just make this significant change, I want to save this copy of, you know, so that it can compare it later to, you know, my new current version, right? And Time Machine just does it every hour.
Jen Yeah, you donât really have much control over what itâs doing.
John But Iâve actually heard of people who use modern version control systems now and they just set up like a repeating process so that every like 15 minutes it goes and makes a new commit automatically. So like while theyâre authoring this book, itâs just making commits every 15 minutes and they just get this nice, like, Time Machine-like repository of all of their changes since they started creatingâ since they started writing the book, which I thought was an interesting wayâ
Jen Yes. So then you were talking about being on a team. I mean, thatâs what people use version control for is Iâm on a team and thereâsâ I mean, right now youâre in Taiwan and Iâm in New York City in the United States, and twoâ
John Itâs really early here by the way.
Jen [laughs] Yeah.
John Itâs 3 am.
Jen Itâs almost 3 pm here, and itâs almost 3 am there. You actually went and had your first sleep and then woke up to do the show. Thank you very much. And you sound very awake, actually.
John Yeah. Well, actually â do a complete tangent here â I started using a standing desk. It is remarkable how much more awake you feel getting out of bed and standing up than it is if, like, getting up and sitting at a desk and putting your head down on the desk and [both laugh] going back to sleep.
Jen Yeah, so if weâre on the same team, weâre on separate continents, we want to share files, you know you work while Iâm sleeping and then I get up and I work while youâre sleeping and we want to be able toâ Weâre working on a website â letâs just, I donât know, a website might be a good idea â together, and we have all of these files, a version control system can keep track of who did what and itâs a way for us to send our work to each other as well.
John Mmm-hmm. Yeah.
Jen And so CVS was next, right? After RSâ err, -CS.
John Yes.
Jen CVS.
John I think it was RCS. Anyway. Nobody cares anymore. [laughs]
Jen [laughs] Nobody cares.
John CVS. Nobody even cares about CVS.
Jen No.
John So CVS was the next, you know, iteration of version control system. And basically people said, âOh well letâs have a central server that, you know, has the repository on it and, you know, everybody canâ They can check out the most recent version onto their working area, right? On their computer and start editing the file. And when theyâre ready to make their change, they push that commit up to the central repository and then everybody else can go and get that new, new commit.â And thatâs basically the way it worked. And it worked very well, as long as everybody was online.
Jen Right.
John And, you know, as soon as you like lose your network connection or, like, you travel â you get on a train, or a plane or whatever â and not being able to get to the central server and not being able to make like a series of commitsâ So, like, âOh, Iâm going to do this feature,â and, âOh! I finished this feature. Well Iâm on the plane. Iâm going to work on another feature.â, and like have no way to actually commit your changes because you donât have access to the central server, that was a huge problem. So thatâs when this idea of distributed version control systems came about.
Jen Yeah, and after CVS came SVN, and SVN is very similar. I mean, this is whereâ
John Yeah, I just basically skipped over that in the history.
Jen Yeah, and I mean itâs kind of the same, right? Itâs not at allâ And again, this is not going to be a higher-level, sysadmin-level kind of explanation. Because, honestly, I donât know. I use these tools because I need them for a functional reason, and then beyond that I just donât care. Iâm really glad that there are other people who care, and there definitely, you know, itâs awesome, itâs a great thing to get into, but I think that for many, many people, especially people who work more on the content side or the business side or the design side, you know, itâs a practicalâ Itâs a tool. We donât care.
John Yeah.
Jen But there were a lot ofâ I know with SVN and CVS, thereâs just all these places where you just start to try to do something and it would, youâd have a problem and getting out of those problems became, I donât know, itâs like everybody on the planet started using all of these things and the original ideas we realized, âOh, that simple way to do the CVS system was a good idea we thought, but it turns out that itâs not so good. Okay, letâs make it one level more complicated to try to make it solve all these more problems.â And then, âOhh wait. Oh, okay! Thatâs really, you know, that doesnâtâ Thatâsâ The basic stuff is easy, but the medium, intermediate stuff is veryâ Ugh, okay, letâs start over!â So then, Git was intvented.
John Well Iâ Yeah, Iâm going to jump in and in support of Subversion slighly, even though I was about to skip over completely in the history,âŠ
Jen [laughs]
John [laughs] âŠbecause CVS was really awkward. Some of its commands were just mind-numbingly confusing, and Subversion said, âHey! We can reimplement CVS and do it better.â So basically thatâs what they did.
Jen Yeah.
John But it still had this problem of, you know, âI would like to make, you know, changes to the repository when Iâm not connected online.â And thatâs where distributed version control systems came in and thereâs actually a lot of them. Thereâs like Mercurial. And Git is just one of the distributed version control systems. And basically the way a distributed version control system isâ One of the first commands you ever learn in Git is git clone, right? And thatâ Itâs named very appropriately. When in a distributed version control system, youâve still got that central server, although thatâs more of a convention. Like, everybody agrees that, âHey, weâre going to have this repository over on Github â be the central place where we all collaborate together, or like in the Drupal world we have a whole bunch of repositories sitting on Drupal.orgâs infrastructure on their servers and we all agreed together that those are the repositories that are going to be the central authoritative repository. But thatâs really just a convention because when you do a git clone, youâre literally cloning the entire repository. Youâre taking the entire repository and making a copy of it on your computer. So then you can do all the things that you used to do with a, you know, a CVS or Subversion system. You know, make, you know, a commit. You can do that all locally.â
Jen And by entire repository, you mean likeâŠ
John I mean everything. [laughs]
Jen âŠlike all the files. So if thereâs 50 files in your pile of files and each of those 50 files has 10 copies for some magical reason. They all have exactly 10, which makes no sense, but letâs just sayâ Then thatâs, you know, 500 files. When you have all 500â Well, it doesnât really work that way, but pretend. Youâve got the equivalent of a history with all of the changes that were ever made, and all the information about who made which change, and all the notes that everybody wrote about what change they made and why they made it, and the dates they made it, and the number that it got â the sort of crazy number-letter long thing thatâs sort of points to that, that particular moment in time â all that information is on your computer on the plane, and thereâs a copy of it on my computer in my house, and thereâs a copy of it on the computer that we said is going to be the official computer because we just made that up and said thatâs going to be the official one. Thatâs in the closet in the office and thereâsâ Right? So, everybodyâs got the entire history.
John Yeah. Itâs literally cloned. Like, everybody has a copy of Dolly the sheep, right? Itâs an exact copy.
Jen [laughs] Yeah.
John And this becomes, you know, quite powerful because youâve got all the revisions of all the files locally. So, one of the things that you can do with a CVS system thatâs really useful â when I say CVS I mean the old systems â was you could say, âHey, I want toâ This one thingâs not working properly. I want to compare it to an old version and see when it stopped working.â Right? And so you can do what was called a diff and basically look at the differences between your current version and whatever old version that you choose. And CVS would go, âOh okay! You want to compare these two versions,â and it would, like, spit out this thing that you could look at and see all the differences, right? And again, if you didnât have access to the central server you couldnât do that.
Jen You had to be online.
John Mmm-hmm. Right.
Jen Yeah.
John And nowâŠ
Jen You donât.
John âŠeverybody has a clone of the entire repository. You donât have to have any network connection. You can just ask your local Git repository, âHey, I want to see the difference between this version of the file and this other version of the file.â And it goes, âOkay! Here you go.â
Jen The thing that Iâve also noticed that, you know, away from the whatever â the mind, the thinking about the big picture, and to the like just specific reality of what this means â is that it feels like now developers and other people who use Git you make what is called a commit. Like, you sticking a flag in the ground saying, âThis is a moment in time when I want to save everything and sort of package it up for everybody else to get access to it.â You make those in moments where it makes sense. Like, âOh, I need to redo all the links with blue instead of green. Okay, Iâm finished. Now Iâm going to jam a flag in the ground. Okay, now Iâm going to go work on the redesigning the fonts and making the fonts look different. Okay, now Iâm done. Iâm going to jam a flag into the ground.â And it used to be moreâ I mean, you know, it sort of the best practice but it feels like people do that more where commits tend to be these moments of completeness or units of, âOkay, this is really ready to go. This is ready to be sent off to other people.â Maybe in part because itâs faster, because you donât have to be online, because you can just quickly make commits right there, boom, on your own machine. Yeah.
John Well, theâ With a, you know, central repository system like CVS, you know, it was quite a bit of work to actually make sure you have network connection and then when people would make commits they would be extra careful about it. And the reason for that is because of whatâs called merge conflicts, right? Actually merge conflicts didnât happen that much in CVS now that I think of it because you would try to make a commit and if somebody else had already make a commit ahead of you and you didnât have that version it would say, âNo, you canât do that. Sorry.â And then you would getâ Actually, yeah, so you would have a merge conflict now that I think of it. It just wouldnât be actaulâ
Jen Itâd just be like, âSorry.â [laughs]
John âSorry, you canât commit that.â
Jen You canât do that.
John Somebody else changed that same file, and youâd be like, âArgh!â
Jen Yeah.
John And then itâd be your job to try and figure out how toâŠ
Jen What to do.
John âŠmerge in this the official repository says is the latest commit and what you thought was going to be the next commit.
Jen Yeah, I mean what youâre talking about just to back up is, like, you and I are working on a project together. Weâre both writing CSS. Thereâs a file called files.css. Iâm changing it. Youâre changing it. WeâŠ
John Mmm-hmm.
Jen âŠthought we were taking turns. I was going to work on it Tuesday and you were going to work on it on Wednesday [laughs] because thatâs how we have to work, but it turns out we worked on it at the same time. So now whatâs going to happen?
John Or like, I forgot to make the commit when I went to sleep and, you know.
Jen Yeah. So now what? Nowâ I mean, you know, it used to be with CVS you had to literally schedule who was going to work on it when. And then with SVN you could try to merge them together. The idea being that like what if I changed a bunch of stuff on the top of the file and you changed a bunch of stuff on the bottom of the file and we didnât actually even touch the same part. Canât the robots be smart enough to say, âOh look! John changed lines 100 through 200 and Jen changed lines 6,000 through 6,100. I can just smash those together. I can see which happened later, and just always choose the later thing.â
John Yeah. And then version control systems did get smarter like that. So, it wasnât just a matter of like, âOh we both edited the same fileâ it was like you literally had the same line in the same file before you would get this conflict. So, you getâ You couldâ Like, I could edit the top lines and you could edit the bottom lines and we both could commit and not have any problems.
Jen And thatâs, thatâs the thing that I really do love about Git the most, is it feels like that example and about 42 others, it just used to alwaysâ You get these error messages and Iâd be like, âI donât know whatâs going on and this is driving me crazy and I donât know what to do.â And it feels like with Git that that happens much less often. That there are times when Git, the robots that are trying to keep track of everything kind of throw their hands up in the air and say, âThis is complicated and I donât know what to do. You need to do this, human, and tell me what to do with it.â But that those moments happen less often.
John I agree. Yeah.
Jen It does know what to do a lot of the time. Yeah. But thatâs the kind of idea as merging is where things kind of get weird, or what do you do if youâve got more than one file that doesnât match. How do you know, you know, which one to use? And thereâs actually more than one way to kind of smash them together. Which way do you want it smashed, andâ
John Yeah. I wonder if itâd be useful to talk about commits and the howâ what are called branches, and you know, looking at the log of changes and talking about the tree of all of the commits. Thatâd be a useful time to talk about that now.
Jen Yeah. I do want to say before we do that though, because we should, but weâ Itâsâ I mean, right now weâre talking about code. Iâve mentioned CSS specifically. You could do this with PHP. You can do this with Ruby. You can do thisâ Write code code. But you could also can do this with other types of files when youâre using Git. And Iâve seen people start to do that more and more, where you can actually put your OmniGraffle documents into a repository. You can put your Photoshop documents into a Git repository. You can put, you know, the Word document with the contract from the client or the requirements that are in an Excel spreadsheet, orâ You can put all of those things into a Git repo. Now, code Git will try to merge. You know, you can say this is CSS. Thereâs a line 72 and a line 75 and Iâll just smash them together. Itâs not going to do that with your Photoshop file. Itâs just going to say, âOh! The Photoshop file changed. Iâm just going to change the whole file from the old one to the new one.â Itâs not going to be like, âOh, look, layer four in Photoshop [laughs]ââ
John That would be sweet if it could do that.
Jen Yeah, it does not do that. It justâ It just takes the whole thing. I think itâs called a binary file and just replaces the older binary file with a newer binary file. But, I think for those people who donât write code, for those people who do handle contracts and requirement spreadsheets and, you know, design files that are not code files, I think itâs interesting to think about using Git for that. And Iâve been really pleased on projects where, you know, thereâs a team working and some of the people are making Photoshop files and they keep changing them, and meanwhile some other people on the team are writing code files. And it seems like the code files, in the past, the code has been in a Git repo or whatever flavor, the repository. Itâs really easy to know what the newest code is. But the Photoshop files keep emailing them to each other or they put them in something like Basecamp or in a project management system. Youâre supposed to go manually download the new copy every morning but you forgot, and so now you spent two hours writing CSS based on the wrong file. Like, Iâve been on a team where people put all of the Photoshop files into the repo as well and sometimes that can be a really great solution to,âŠ
John Mmm-hmm.
Jen âŠyou know, final-final, final-final-real-final [laughs]âŠ
John Yeah.
Jen âŠto know which one is the file.
John So it used to be the system administrators would, like, what you just described would make them hear fingernails on chalkboard, because theyâre like, âYou cannot put that big of a binary file into the system repository! [shouts]â
Jen [laughs]
John But that was back when we had itty-bitty tiny hard drives, really. I mean, [laughs] because it would keep a copy of every single version of that file. So like, if you had a hundred meg. Photoshop file, it would keep, you know, 17 copies of [laughs] each of that file, and it would be full copies. So youâd have like 17 times a hundred megs., right? That was how much space you would be using for that one file.
Jen Yeah.
John Which is why the system admins would go crazy. But now we have bigger hard drives and itâs not that big of a deal.
Jen Yeah, and faster connnections. Thatâs only going to work if youâre in a place around the globe where you have a faster connection. If youâre paying per megabyte, then you probably donât want to do that. And you probably donât want to put your giant video files into your Git repo because that could take up more space than you want. If youâre changing them over and over and over again. So there are, you know, definitely reasons not to do it, but itâs kind of exciting, especially as a person who is a designer and all the different files that designers can use. You can totallyâ Designers can use this too. Designers can put all of their work in there, share work, keep track of things, have backups, etcetera etcetera, shove every thing up to Github so youâve got an off-site backup.
John So [inaudible username, 27:00 mark] in the chatroom says that thereâs a visual version control system, called LayerVault, which I have not used or heard of, so I guess weâll leave that an exercise to the reader to, err the listener [laughs] to figure out if thatâs actually useful for like Photoshop and video stuff. So.
Jen Yeah. So, okay. So branches and the other stuff you said. [laughs]
John Right. So, now comes the tricky part in the audio podcast where I try to describe, you know, the beauty of the tree. [both laugh] So when you first create a repository, you basically have to tell it to initialize your Git repository and you say, âOkay, hereâs all of my files, and Iâm going to create what is called a commit that just says, you know, hereâs all the filesâ, right? This initial commit is often what the commit log message says. So, Git will take a snapshot of those files and store that as a commit. And next to that commit, itâs got this really long hexidecimal number, which is called a SHA-1. And youâll see this in technical stuff a lot, and youâll frequently see this in GUIs. Thereâll be, when you look at the log of commits, youâll see like this really long hexidecimal number like 52CFEBDDE48D46E6EB52â
Jen [laughs]
John Iâm about halfway through an actual SHA-1. Iâm going to stop here. [laughs] And basically, all that is is a unique identifier, right? So it creates whatâs apparently a completely random, really long 32 digitâ err, hexidecimal digit. And thatâs just so that it can keep track of all the commits individually and it has like a unique name. But that unique name is really awful for most human beings to remember. Like, Iâm not going to remember that if I want to compare my most recent version with the very first version in the repository. Iâm not going to remember that that first version was called 52CFEBDDE48Dâ You know, right? So, Git allows us to basically add labels to these things, and as we go and add another on top of it this new change, if you sort of try to visualize a, like a dot for the first commit. And then a little line sort of going upwards, and then a second dot for this second commit, and as you add new commits that line continues upwards and new dots and sort of like a big sort of connect-the-dot thing that goes upwards from the initial commit. And thatâs the start of a very simple tree, and you can think of this just like in nature, right? So you just have the initial, the trunk of the tree coming out of the ground. Nothing really interesting yet. But it sort of just comes straight up. And Git will label that sort of initial trunk of your tree with a label called the master branch. So itâll be called master.
Jen Yeah, theâ
John Right.
Jen I donât mean to interject in here. Theâ The way youâre describing it is in a vertical line and sometimes I see it drawn horizontally when people draw this visually, and itâs like a timeline with these dotsâŠ
John Sure.
Jen âŠas if it were, you know, moments in time on the timeline. And it used to be that thatâ I didnât even know it was called a SHA-1. By the way, Larry in the chatroom is telling us that itâs a 48 characterâ
John Oh, 48. Okay.
Jen Notâ Just to be accurate. Theâ It used to be that they would count it like this is commit #1. This one is 2. 3. 4. 5. And my first reaction in seeing something like this crazy, long number thatâs not even just numbers â itâs got a bunch of letters in it â is like why? [laughs]
John Yeah.
Jen Canât you just number them like 1, 2, 3â But it turns out numbering 1, 2, 3 creates problems.
John Mmm-hmm. Yep. So Subversion used to number them 1, 2, 3.
JenYeah.John So like R1, R2, R3, which stood for revision 1, revision 3, you know so likeâŠ
Jen Yeah.
John âŠwe just have this linear list of numbers which made it sort of relatively easy to remember theâŠ
Jen Right.
John âŠsecret commit number for whatever version that was that you were thinking of.
Jen Yeah. Youâd be like, âThatâs R627â.
John Yeah. But that assumes a central server. Now what happensâ
Jen It assumes people are not working at the site and time and different parallel universes. And ifâ
John Right.
Jen Yeah, if one person is on 761 and somebody else is on 761, then who gets 762? Who gets 763? What if everybodyâs on an airplane? How do you know whatâ And thatâs why itâs this giant, giant long number. Because Git makes a number up, and itâs like, âOh, itâs 65439Q â not Q â CEF-somethingâ, and then itâsâ They make up another number over here, and make up another number oveer here, and everybody gets off their airplanes and jams them all together. The odds are that two commits have that same crazy number are, like, a gazillion bazillion never going to happen. So, [laughs] itâs okay because everything is uniquely numbered and the numbers donât actually mean anything andâ
John Yep. Yeah.
Jen Everything has a number that is different than everybody elseâs number. Even if they were working on separate airplanes for a year or something, the odds of their being a problem is very, very small.
John Right. Exactly. So if youâve got two people who got an identical clone of the repository at this paricular time, and then they both go and create commits at practically the same time, you just canât give it the same number. So, like, youâve gotâ Everybodyâs got five commits and I go to make the sixth commit, you canât call it commit #6 because somebody else just did the same thing at the same time and thereâs no way to sort of [laughs] to resolve that fundamental problem with counting.
Jen Yeah. Yeah, and mostly, you know, humans donât need to see the 48 number, the character number, and if you ever do need to handle the number they usually getâ they do get abbreviated and you can just use the first â I donât know what it is â five digits or something andâŠ
John Right.
Jen âŠnot worry about it. But really the whole point is thatâ
John Yeah, the only reason I brought it up is because youâll see those in documentation all the time.
Jen Yeah.
John Andâ confusing.
Jen Yeah.
John Really, from an everyday standpoint, you donât really need to know that thereâs a really long number associatedâŠ
Jen No.
John âŠwith it. But the sort of fundamental thing thatâs important to understand is that Git does track each of these commits individually and it has a unique identifier for each commit so it knows what to do with them. And then we basically add these sort of human-friendly labels to whatâs going onâŠ
Jen Yeah.
John âŠso we can keep track of whatâs goingâ So this master branch. The master label is basically pointing at the most recent commit thatâs in our repository.
Jen But this imagining a line with dots all on it being this, the branch, the longâ itâs a timeline, the thingâ
John Mmm-hmm.
Jen I mean, when I first started using Git, I first first started using it on Github and I found Github incredibly helpful to figuring this stuff out, because they actually do have a graph visually. If youâre working on any project, thereâs a tab called âNetworkâ, and you can click on that. You can actually go over to Github now and just look at any, I think you can just without an account just go to Github.com and click on anything thatâs there, anybodyâs project, and then click on the âNetworkâ tab and you can see a graph, literally of this exact thing: a big line with a bunch of dots on it. And I think if you hover over the dots, like, more information will show up about what each of those dots is. Each dot representing a commit. Each dot representing a pile of files or pile of changes or, you know, maybe some files got added, some got deleted, or something happened and they were packed up into a thing. And then branches, youâre going to explain branches.
John Yeah.
Jen Branches are where you canâ
John So, letâs say I wanted to start working on a second version of the site, right? So Iâve got this master branch where weâve been working on this site together, and we donât want to, like, lose the current version of the site while we start working on the new version because invariably, you know, a month into weâre hacking on the new version thereâs going to be some giant security hole or, like, you know the client needs, like, this one thing done really, really fast and you have to make changes to the current version at the same time as working on the new version. So what you end up doing is creating a new branch. And this is basicallyâ So we got this dotted line extending the air. We tell Git, âHey, Iâd like to create this new branch, and weâll call it version2â. You can name your branches whatever you want. So weâre going to create this version2 branch, and then when we make a commit to that version2 branch, itâs just basically going to create like a little line off of the most recent commit that weâve done, sort of angling off to the right. And now weâve got literally a branch coming off our main tree. As we add fixes to our current version of the site, the master branch will continue straight up, and then weâve got this sort of side branch for version2.
Jen Itâs literally, literally a parallel universe. Like, in this universe, we have a homepage that has six boxes on it. But weâre thinking about maybe doing it differently. Weâre designing this from scratch, and weâve got the homepage with the six boxes. And so we want to try out what it might be like if we have a homepage with eight boxes, but we donât want to destroy the one with six boxes, and we donât really want to start a whole separate project. This is all one website, so letâs create a parallel universe, and in the parallel universe weâll change all the stuff around and weâll try out a design with eight boxes, and change all the colors and make the type bigger, and whatever else that gets requested. And then we got these two different worlds, and you can kind of switch, like literally just switch from one world to the other world and back and forth. And be like, âClickity-click-click. Oh okay, letâs look at with six boxes, look at it, talk about it in this meeting. Clickity-click-click. Oh, now weâre back to the world with eight boxes.â Itâs pretty powerful. And one of theâ Thatâs one of the things thatâs very easy with Git: make branches. And itâs easy in such a way that once you know how to use Git, and we havenât yet talked about the tools and how exactly to do this stuff, but once you learn that kind of stuff, making branches and switching between the branches is relatively not hard. I donât know if I should say easy, but itâs not that complicated. And it means that you can take bigger risks sometimes. Maybe youâre going to start workingâ You got everything working and you finished this thing that you were doing. It took you four days and itâs all done, and now youâve got to start working on a new thing and the new thing is going to be kind of weird and hard and youâre afraid youâre going to break everything, and you kind of donât want to mess up the perfection of the fact that it works right now, [both laugh] so maybe you make a new branch. And youâre like, âOkay, Iâm going to go off in my branch in the parallel universe world, and Iâm going to do all this risky stuff that Iâm not really sure how to do. And if I screw it up completely, I can just go back to the other world where everything works and throw away that whole branch. And just be like nevermind. Go away.â [laughs] And it just goes away! And then you donâtâ You know, you can back up in a certain kind of way. You can get back into the working universe where everything works. Itâs great for teams too because maybe youâre on a team and everybodyâs sort of pushing all their really, really finished work to master and thatâs the convention that you have, the agreement you have with each other, that masterâs always going to be stuff that really, really works. And maybe each person is on their own branch so that you can do a bunch of stuff on your branch and somebody else can do a bunch of stuff on their branch, and you donât kind of mess each other up unless you want to.
John Mmm-hmm.
Jen Or sometimes people make a separate branch for each ticket. You know? Theyâre like, âWe got 700 tickets to get done for this project. Letâs make a branch for every single ticket, and that way weâll know where the work is for each ticket.â You can do that if you want to. I think the way a teamâs structure themselves and the way they set up a project is really up to the team and up to the project to figure out what makes sense. But those are some of the ways that I know people have worked if they want to, you know. Or sometimes people just [laughs] do what I do and just shove everything into master until my colleagues are like, [laughs] âWill you stop breaking everything?! You really need to make branches for what youâre doing.â And Iâm like, âOh, okay!â [both laugh] Thatâs probably the most commonâ
John Yeah. Feature branches are really useful, especially when youâre, like, you know intentionally breaking something in order to redo it. It can be very disrupting if you just continue to work, you know, make all of your changes on the master branch, which is what everybody else is using. And youâre breaking as theyâre, you know, pulling those new changes over. Their site is being broken in the exact same way as youâre doing it intentionally, except that they donât know whatâs going on. Right? [laughs] So, if you instead create a new feature branch like this, you know, instead of creating a branch called version2 you just say my-crazy-feature, right? So Iâm going to call my-crazy-feature, new branch, and do all my work there because everybody else is still working off of the master branch theyâre not going to see your work until you decide to put it back onto the master branch. And the way that you do that is whatâs called merging, right? So weâve got, weâve got this new branch that shoots off to the right from the master branch, and thatâs whatâs called diverging, right? Because they split from this common ancestor point and now you have two separate lines of parallel development, right? Once you stop breaking the site and youâre like, âHey! It actually works now!â you can do whatâs called a merge and you will literally take the very end of your feature branch and the very end of the master branch and knit it back together. So youâve got a line coming off of your feature branch and a line coming off of your master, and they come together to a single point and thatâs a new merge commit that merges those two separate branches back into one branch.
Jen Yeah, itâs pretty miraculous [laughs] actually.
John Yeah.
Jen Because it maybe that youâve been on a branch for a month, and it maybe there are 14 other people whoâve been working on master and you may have changed a lot of stuff and didnât change a lot of stuff that everybody else did, and meanwhile they changed a bunch of stuff and thatâs all got to get smashed together in a way that hopefully actually really works.
John Git does a really good job of merging stuff together.
Jen Yeah.
John Technically, Subversion had merge capabilities but they did not work so very well. Thereâs, like, all this sort of computer science-y ways of merging trees and graphs as they call it, and they were just real crap at it back when Subversion was created and it got a lot better since then, so. Thatâsâ Somebody in the chatroom was saying, âCan you describe octopus merges?â and we said, âNo!â [both laugh] But thatâs like one of the computer science-y terms that, for strategies of how to smush the stuff back together.
Jen I like saying smush back together rather thanâ [laughs]
John I like toâ I like to alternate so that people remember itâsâ It is a merge. This is what a merge is. [laughs]
Jen Yes. Yes. Thatâs true. Yeah, youâre using the realâ
John Itâs not like two bananas and you smush them together. [both laugh]
Jen No, using the real words is good because then also you can Google those real words andâ I just frequently donât remember them. Itâs funny. Itâs like once it works it justâ Yeah. And also merge is a word thatâs usedâ I mean, letâs say Iâve cloned the repository. The repository perhaps was born somewhere else in the world. So now I have a clone on my computer, and Iâm working, and Iâm working locally, and Iâm doing a bunch of things, and I work all day, and I make three commits during that day at three different moments when I feel like things have kind of been finished. And then I get to the end of the day and I want to take all my work and shove it off to the rest of the team. I havenât done that yet. Maybe for some reason Iâve just kept everything to myself. I feel like no, now Iâm really, really ready to share this work. And so then Iâm pushing it. And I push it off into whatever, wherever it goes. And then laterâ
John Thereâs actuallyâ Well, I was going to say: whenever you push it, thereâs a couple of things that might happen.
Jen Yeah.
John Right? One is that nobody else has made any changes to the repository, this sort of central repository that everyoneâs decided is the central repository. If no oneâs made any other changes, the central repository goes, âOh! Hereâs new commits from Jen. No problem,â and it just merges them in with, like, the master branch if youâre working off a master branch, right? The other thing that might happen is, âOh, well John happened to have made some commits ahead of time and weâve aleady added these extra commits to the master branch. So my master branch is different from your master branch, and I cannot just add your commits directly on top of it.â So itâll say, âHey! No! You canât do this yet because you were missing some of my commits.â And all you have to doâ Itâll interrupt your git push and say, âStop! You canât do this now because youâre missing commits.â And all youâll have to do is do a git pull. So then youâre basicallyâ What a git pull is, actually, itâs two steps: itâs fetching all the recent commits from the remote server, and then doing a merge. So when you think about it, even though youâre both working on the master branch, you still have diverged, right? Because your master branch used to be the same like three commits ago, but has diverged because youâve got these new commits on the remote server that you donât have on your local server, and youâve got some commits on your local server. So you effectively have this, this branch of the remote master and your local master. And so when do a git pull, itâs fetching the commits from the remote server and then it does a merge. It, you know, stitches these two lines of development back together. So it takes the remote master and your local master, creates a new commit that stitches them back together, and then says, âOkay! Iâve pulled and it wasâ There was a clean pull.â So, like itâs done a clean merge. So now youâve merged them back together but youâve still just sort of done that locally. And now you can push again, and itâll push that merge commit to the remote server and say, âOkay, look, I just merged my work in with yours. Is this good?â and they should say, âYeah! Works for me!â, because it just looks like a new set of commits that apply cleanly now to what it thinks of as the authoritative master branch.
Jen And what you just described I think is one of the moments when people hit the wall for the first time. Youâve cloned the repo. Iâm working. I did a bunch of stuff. I made myâ And we havenât talked about even how to make a commit yet. We can back up and do that. But I made a bunch of commits and I go to push them, and I get an error message. That error message, right there in that moment, is the thing that I think is the number one âWhat?!â
John Yes.
Jen And thatâ Watching people try to solve that is a place where Iâve seen people really screw things up, and in fact in ways that I didnâtâ I would have never thought was even possible. [laughs] So, that was one of the first things that I felt like was a bigâ Okay, now Iâm starting to get it, is once I knew okay I go to push, I get this error message that I donât quite understand. What that means is I need to pull. Heh. Sometimes that error message, the words and the error message, are pretty clear. Sometimes theyâre really not. Like, Git Tortoise is a terrible tool. Itâs aâŠ
John [laughs]
Jen âŠtool that you can use on a PC that puts some Gitâ some powers of Git into your browser actually. And you can right-click in the browser and do some stuff. And I donât remember what it tells you for that message, but whatever it tells you makes it sound like you should click a checkbox and hit the button, and when you click the checkbox and hit the button you, like, screw things up. Like it justâ Donât do that. [laughs] First Iâd recommend do not use Git Tortoise, but if youâre going to use Git Tortoise then absolutely be careful about what Iâm talking about. But thereâsâ Sometimes thereâs, you know, there are tools that will offer you a chance to check a box and force and you justâ The answer is no. Donât do that. Donât, donât, donât. No, no, no, no. What you need to do is pull.
John Wait, wait, wait. So Git Tortoise told people to do a force push? Because basically if aâ Force push is a term thatâs in Git and basically that means that youâre going to be the bully. [laughs]
Jen Yeah. Wipe everything else out and just do what I ask.
John Youâre going to push yourself. You know, push commits out of line and say, âScrew you!â You know, âIâm taking your lunch money.â You know, âThe master branch is what I said it is, and I donât care what all of the other stuff,âŠâ
Jen Yeah.
John ââŠall these other commits that people are making.â
Jen I donâtâ Git Tortoise was doing another thing, and I donât remember if it was that tool or another tool, but there have been tools that Iâve seen â especially early on in the Git world, maybe theyâve changed since â but this was a year or two, two years ago where the tools would be like, âHmm. I seem to be having trouble. Would you like me to force?â [laughs]
John Thatâsâ Thatâs a really bad collaborative tool.
Jen Itâs really bad. Because, basically youâre sayingâ Itâs basically saying, âHmm. It seems like some other people did some work. Would you like me to erase it for you?â [both laugh]
John Yes! Thatâs exactly what itâs saying.
Jen And the answer is no! So, one thing is donâtâ If you see an option toâ If you ever see an option that says, âWould you like me to force?â the answer is no, unless youâre a master and a ninja and you know this better than what Iâm explaining then fine, go, do whatever you want. But if youâre a [laughs] a person whoâs still learning this stuff and thereâs an option to force, the answer is never.
John The ninjas are all on the command line anyway.
Jen Theâ Yeah. Theâ But really, this problem. Youâre going to go to push. Itâs going to go, âblurp blub blub da blub blah, I canât,â heh. And youâre going to go, âUhâ, and the next step is to pull. Just pull. However, whatever tool youâre using, pull. Because for whatever reason, it really wants to do the merge on your computer. It doesnât want to do the merge up on Github or off in the ether somewhere. It wants that merge process to be handled while you are watching on your computer locally. So you have to pull and get all the stuff from everbody else and then do the merge where you are, and then once the merge is done take the whole merge, the whole merge â and this is where it Git Tortoise screws things up â and send that whole merge back up to the Universe. Git Tortoise gives you the opportunity to pick through that merge.
John I can tell you why Gitâ I can tell you why it does want you to do it locally, is because like I said, you know, Git does a really good job of smushing the stuff back together most of the time.
Jen Yeah.
John Itâs when the things go wrong that you need to try to massage the two bananas back together locally. [laughs]
Jen [laughs] The peel is not fitting around the smashed bananas.
John Yes.
Jen Yeah. Theâ Yeah. And it willâ We should talk about that in a minute, is how toâ Because thatâs the number two problem that I see. The first one is, you know, you donâtâ You didnât realize you didnât pull because you donât always have to and you forgot that you might need to, and then you got lost. And then the second problem is what to do when you do pull and you have a merge conflict. But yeah, thatâs where Git Tortoise would go wrong, is Git Tortoise would give you the opportunity once you did the merge locally and you would successfully finish the merge, it would supervise the pushing all of those files and it would give you the opportunity to only push some of them and not the rest. Some of the commits and not the rest of the commits, or like cherrypick through the merge and only send some of the stuff. I was on a team once where many people were doing that and they would beâ They would basically be deleting work because they werenât pushing the entire merge. They were only pushing some of it. It justâ It wasâ I donât know why thatâs an option in Git Tortoise, but yeah.
John I get in this habit of rightâ Like Iâve just made a commit and I want to push it up to the server, and I go, âYou know what, Iâm going to check and see if thereâs any new commits from other people before I push my stuff.â So Iâll do a git pull first and do a git push. So I donâtâŠ
Jen Yeah.
John âŠbecause I remember to do that, I donât often see the problem where I push something and it says, âNo! You canât.â I donât see that error message very often.
Jen Because Iâ
John I used to see it a lot because Iâd forget to do it.
Jen Yeah. No, itâs a good habit. If you just always pull and then push, youâre fine.
John Yeah.
Jen The thing you do have to do though before you pull, is you have to commit everything that youâve done. So if I sit here and I work for three hours, and I commit the things I did, and then I work for another hour and I do notâ I havenât committed those. Theyâre like half-baked. I got all this stuff sort of not finished. But I want to push what I already finished, and Iâ So I need to pull. I canât pull with sort of half-done stuff. I have to figure out what I want to do with everything thatâs half-done. And I have to commit it or I have to sort of, if I want to be more advanced, put it in another branch or move it off into whatâs called a stash, or like thereâs options. But basically I need to go ahead. Usually I just go ahead and commit everything that I have. Then you can pull. Then it will merge. And then you can push that whole merge. I think this is where people are like, âThatâs too hard! I donât understand what youâre talking about!â [laughs]
John Mmm-hmm.
Jen Because I get it. I get thatâ I mean, I can hear ourselves. I can hear myself out loud, going âI want this to be simple.â It is a little complicated, but itâ I feel like once youâve done it a dozen timesâ
John And speaking of complicated [inaudible username, 54:31 mark] in the chatroom was just asking can you describe rebase right now. And while technically itâs related to what I just described, they would horribly confuse 99% of the peopleâŠ
Jen [laughs]
John âŠat this point, so maybe we can cover it, like, in IRC or something. If we get to it at the end of this conversation, great. But itâs a more advanced topic right now.
Jen Yeah.
John So.
Jen But, so you work locally,âŠ
John Yeah.
Jen âŠyou make a commit, you pull everybody elseâs stuff, I donât reallyâ You just, maybe you see some things go by. Itâs somethingâ You see the word merge flash by, and then you push.
John Yeah. If you do a git pull and thereâs no commits on the remote server, then it just goes, âYouâre up-to-date already.â
Jen Yeah.
John âNo problem.â
Jen Yeah.
John And if you do a git pull and thereâs commits on the remote server that you donât have, it will, you know, itâll merge it together and create a new commit for you on your local system.
Jen Yeah.
John And then when you push, youâre going to be pushing, you know, all the commits. You mayâ Plus this merge commit up to the remote server, soâ
Jen Yeah.
John That is this concept of merging and these things together that youâre absolutely right. That is the first thing people will, like, donât get and it screws them up and they never want to use Git again, because they see these error messages, like âI donât know what to do!â
Jen Yeah. So, Iâm debating whether we should talk about merge conflicts or we should go back and talk about how to make a commit.
John Hmmm. I think letâs go back and talk about how to make a commit because some of the tools we need to do a merge conflict, you know, you actually describe the tools themselvesâŠ
Jen Yes.
John âŠand if we havenât described how to make a commit, that might be useful. [laughs]
Jen And letâsâ This is a good place. Let me jump in here with, talk about our sponsor because sponsors are cool. [laughs] The In Control Conference, which is coming up in December in Hawaii, December 3 and 4. Thereâs a bunch of pre-conference workshops on December 2. Thereâs two days of sessions on December 3 and 4, all of what is called The In Control Conference. And then on December 5, thereâs another day called The CSS Dev Conference. All of these are in Honolulu, which is kind of cool, especially I think Iâve been talking about this conference for the last several shows as if everyone lives in the United States, which is just dumb. Iâve been reading a book about adventures in South America, reminding myself that, like, I really need to cut it out assuming everybodyâs in the United States. For a lot of peopleâŠ
John Yeah, I for one live on a different tropical island in the Pacific.
Jen [laughs] Yes. Well, and like getting to Hawaii is wayâ How far is it to Hawaii from where you are?
John Itâs about halfway between here and San Francisco, so.
Jen Yeah. So this is a really good thing that a lot of people who are in Asia might want to check it out because itâs a lot closer thanâ Because a lot of these speakers tend to speak in Europe or in the U.S., but this is a chance for people who are in other continents to see them without travelling nearly as far. Karen McGrane, Kristina Halvorson, Chris Coyer, Jessica Hische, Brad Frost, Dave Rupert. Really smart people, all talking about really fabulous things, many of which theyâve been on this show, talking about CSS, talking about content strategy, about mobile, HTML5, jQuery, how to build a modern website with great technique, great business strategy, great architectural strategy, how to get it done in the amount of time and with the number of resources that you have. Real specifics and big picture stuff. And then the CSS Dev Conference is a whole day just about CSS, with a lot of other really smart people: Jonathan Snook and Paul Irish and bunches of people. You should go check out cssdevconf.com and incontrolconference.com, and you can look, you know, look at the schedule and the dates and the fabulous hotel on the beach in Hawaii and check out all of the information. Thereâs alsoâ
John Yeah, so if I can jump in here a little bit.
Jen Yeah.
John Sometimes people donât know these names and Iâve been updating my bio since Iâve been working on the Sass and Compass book, but Iâve been doing this stuff for almost 20 years. Like next April itâll be 20 years that Iâve been on the Web, and the people that you listed off, like my jaw dropped open. Itâs like wow! These are a great list of people that you definitely want to go see them.
Jen Yeah, you know, like Dan Cederholm. [laughs] Yeah. Thatâs who I learned CSS from literally reading his books. Yeah. Thereâs a coupon code: ALOHAAHEAD. If you use that code, you get a hundred bucks off. You can always go check out the show notes to go look that code up again and figure out how to spell it, get the links to these two conferences. The show notes, by the way, are at 5by5.tv/webahead/40, where you can see all the links to things that weâre talking about and whatever else that we want to put in there once we get done. So thank you so much to Environments for Humans, the folks who are putting on these two conferences. Theyâve been sponsoring quite a few episodes of The Web Ahead this fall, and itâs been a giant help. So yes, you listener can help the show by going to their websites and checking them out even if you think that Hawaii is a pipe dream. You can go get specific about your pipe dream. [laughs] Let them know that youâre thinking about them because they sponsor the show. So thanks.
Jen Commits. So, John, how do you make a commit?
John So, I wasâ Say theâ Letâs start right at the very beginning, which is youâve never used Git before and youâre like, âOh, I definitely donât want to use the command line,â so youâve installed some GUI. Iâve got Git Tower here in front of me right now, which by the way has a 30-day trial, which is what Iâm using right now because I usually use the command line. [laughs] But, the first thing that any of these tools will ask you is basically, you know, âTell me your name. Give me your contact info.â And the reason for this is because not only does Git keep track of each version of the file, it keeps track of who edited the file in that commit, right? So, the author of the commit is, you know, is you, right? So it needs to know your name and your email address. And thatâs a convention. That, Git uses. It has to know both of those things. A lot of people donât like putting their email messages on, like, pubicly available servers. Theyâre afraid of spam and all that stuff. And there are some really easy solutions to this: One is use a fake email, which I think kind of sucks. Donât use that. The other one is to, you know, weâve all got like three or four Google accounts. Why not just create another Gmail account [laughs] for that, which is what I did. So, like, Iâve got virtually.johnalbin-at-gmail.com which Iâm using using for all of my commits. And itâs a real email, and I check it occasionally. But, it needs to know my name and my email address. And all of these tools will ask you for that so that it can identify you when you make a commit. So, if youâre using the command line, you basicallyâ Actually no, letâs do it from the GUI standpoint, because most of the people donât want to use the command line. In Git Tower, itâll show you a list of all the files that have been changed, which is very convenient because you donât want to browse through the entire project just to find the one file that you edited, right? So it just lists all of the things that have been changed. And then thereâs a little checkbox next to each of those files that says âStagedâ. Itâs unchecked and you just need to check it to stage it. And the reason for this is that some version control systems will just, when you make a commit, itâll check in every single change that youâve made in the entire project. And Git says, âYou know what? You need to tell me explicitly which files you want to add to this commit before I make a commit.â So you basically have to take all of the files that you want to be in the commit and stage them. So you, in the GUI, you click the checkbox that says âStagedâ and if youâre on the command line you would say git add and then the filename, and you would be adding the file to the staging area. So now youâve got all of these files that are in your staging area, and then you can actually make the commit. And in Git Tower, itâs just a button that says âCommitâ, right? And itâll pop up a dialog saying, you know, âGive me a commit messageâ, right?Because I want you to describe briefly what changes that you made so that people can get a sort of a human-readable message of this change that you just made, instead of having to actually look at individual files to see what changes youâve made and sort of figuring out from the context of this giant context of the project what happened, right? So describe it in human terms what youâre doing for this commit. And then you fill that in in the commit log, and then you say, âOkay, Enterâ or whatever, and it takes that commit message, it takes your name and email, and bundles it all up into a commit.
Jen Yep.
John What do you think? Is that a good description?
Jen [laughs] I think so. Yeah. I think itâs also good illustration of sort of what itâs like to do it from a command line versus from a GUI, because I feel like learning to do it from the command line then thereâs a mental model that I need of, âOkay, so thereâsâ I canât see them â theyâre invisible â but thereâs a bunch of files and some of them have changed and the rest did not. So then I need to know which ones changed. So thereâs a command I can run. Itâll give me a list. And then I need to tell it to put everything into a staging area, and then I need to actually make a commit out of whatâs in the staging area, and if Iâm not sure whatâs in the staging area I can always ask it and it will tell me whatâs in the staging areaâŠâ
John Right. And theâ
Jen Itâs like working with all this invisible stuff, and then having to sort of have it in my own head of whatâs happening.
John Yeah. So if youâre on the command line, git status will give you basically a text version of the things that you see just naturally in all the GUIs.
Jen Yeah.
John So git status will list all the files that have been changed, but itâll also list all the files that youâve aleady stagedâŠ
Jen Yeah.
John âŠthat are in the staging area. So thatâs really useful to know that oh these files are ready to be committed as soon as I decide to make the commit, and then these other files have been changed. And the thing is you can actually add a file to the staging area and then when you go and edit it again after youâve added it to the staging area, that new change isnât staged. Itâs the old version of the file when you added it to the staging area that it remembers.
Jen Right. Right, right, right. Right. Thatâ We canâ Thatâs a little bit advanced. We can get back to that.
John Thatâs also useful to know, right? So like,âŠ
Jen Yeah.
John âŠâIâm going to make this change and oh! Iâve got these files in the staging area and oh! Wait, I forgot to do this one thing,â and then you go and make that one changeâŠ
Jen But it didnât get it.
John âŠand you forget to add thatâŠ
Jen Right.
John âŠnew change to the staging area and then you go to make your commit and itâs not what you wanted becauseâŠ
Jen Yeah.
John âŠitâs missing this bit.
Jen Yeah, and this is whereâ And I haveâ I have soâ
John Thatâs the second place where people get screw up.
Jen Thatâs true. [chuckles] I have so much respect for people who live on the command line and do tons of work on the command line. I think thereâs certain jobs, certain roles in our world that working 100% on the command line totally makes sense. If youâre a sys. administrator thatâs what youâre doing. If youâre writing code and youâre very muchâ your hands are on the keyboard all day, it makes a lot of sense to do a lot of the stuff on the command line. I feel like for designers, even the commands that I know and the command line stuff that I can do perhaps even faster on the command line than through a GUI, I like doing them in a GUI because my brain is in a visual mode and not in a text mode and I want to stay in a visual mode. And also I feel like a lot of this stuff is easier from a GUI because you donât have to necessarily remember to think about the invisible things and you donât have to necessarily have the whole mental model in your brain very completely. Like, you were describing with Git Tower. I use Git Tower a lot, constantly actually. It will literally list the files, and then thereâs a little checkbox, and youâre like, âOh yeah! Of course! I have to check the ones that I want.â And you check the ones that you want. You donât check the ones that you donât want. Like, thatâs completely obvious what that means. You donât need to know the words staging area. You donât have to realize that youâre staging. You justâ Youâre just like, âOoo! Check, check. Not check. Check.â And then you click the big commit button and it brings up a dialog box. It makes itâ Itâs clear where youâre putting a message in there, you hit the button, boom! You made the commit. You can see the list that used to have, you know, you had eight files that changed and you committed four of them and now you have a list thatâs four files because those are the ones that you didnât change.
John Mmm-hmm.
Jen Or when you go to add files or you want to delete files in Git Tower, itâs all the same. You just check all the boxes. If youâve renamed a file, it seems like itâs going, âHmmm. This one disappeared. I donât know where it went. Do you want me to delete it? Hmmm. This one appeared out of nowhere. I donât know what this is. Do you want me to add it?â And then when you click both it goes, âOh yeah yeah! You just renamed it.â Itâs a R with a yellow, I donât know what that means. [laughs] Looks good to me! Clickity-click-click-click, go! Where I think with the command line, you do have to have a bit more mastery and to realize I need to do this with these files, this with these files, this with these files. Thereâs different commands. I need to know what these commands are. I need to spell all of the words correctly. Which is cool.
John Yeah, if youâre on the command line, you definitely need to have a more concrete understanding of the architecture of Git and have these conceptual models sort of in place and ready to go,âŠ
Jen Yeah.
John âŠbecause itâs really easy to get lost at the command line without them.
Jen Yeah, it feels a little bit like, you know, hacking through the forrest without a map. [laughs] When you, you know, on the command line where I donât really know and honestly I donât want to know. I just want to get my commit made.
John Yeah. And Iâm going to be honest: when I first used Git and thereâs a guy out there called Matt Butcher who I co-wroteâ one of the co-authors with Drupal 7 Module Development Book, he was on the project with me when we first used Git and man I did not want to use that system ever again after we used it. And because there were no GUIs at the time, it was just command line, and Git on the command line is actually improved so much in the last, like, three years. This was three years ago when I used it. And it had like the most unhelpful error messages ever. [laughs] You know, so these problems that we were talking about that the kind of problems people run into, like I would get those common problems and then the error messages would just say, âNo, sorry, you canât do that. You want to do a git push? No.â [both laugh] That was the error message. âNo. Nah. Forget about it. No.â
Jen Yeah. Like, itâs more helpful if you remind me that I should pull. [laughs]
John And now the command line does remind you. Itâs like, âI canât push right now because there are commits that you donât haveâ, and you go, âOhh! Okay, thatâs a useful error message.â Right?
Jen Yeah. And thatâs more complicated. I mean, I think Git from the command line is more complicated than SVN from the command line because thereâs, like, three or four steps instead of one or two steps. There are good reasons for it, some of which weâve already talked about, and thereâs no way I want to go back. I mean, Iâm actually at the point where I almost feel like saying to potential new clients, âYouâre using SVN? Iâm sorry, you canât hire me. [laughs] Weâre going to be using Git for this project.â But, it is more complicated.
John Yeah, once you become, like, a real Git masterâŠ
Jen You donât want to go back.
John and by that I mean you have to use it from the command line, that kind of Git mastery. Thereâs actually a way that you can tell Git to pretend that the Subversion server is a remote Git server.
Jen You can actually do that from inside Git Tower, and I have.
John Really? Oh okay.
Jen Thereâs a project Iâm doing that now with, yeah, with Git Tower when thereâs a whole pane for repositories, thereâs a place that I just click the button and add a repository, the little drop-down says, âAdd Remote Repositoryâ, âAdd SVN Repositoryâ.
John Well cool!
Jen You can just boom. And thatâs, thatâs definitely a good way to work. If you are interested in Git and you want to use Git but youâre on a project thatâs using SVN, you can check out the SVN repo through Git and then locally get to do all the juiciness of Git but meanwhile interface with everybody else using SVN. It doesnât give you everything that Git would give you, but it gives you a lot of it, especially locally. It gives you some of those tools.
John Yeah. If you have any leverage with a client, I would definitely say stop using Subversion. Use Git.
Jen Yeah.
John But, you know.
Jen But my point was that even though Git is more complicated in some ways, itâs still better. And I do think that anybody who wantsâ I mean, if youâre an aspiring developer and youâre working to learn Objective C or Ruby or, you know, PHP and youâre working on a computer science degree orâ I think you should go learn Git from the command line. Like, thatâsâ thatâs a great thing. Maybe you use a GUI for a year or six months until your mental model is in place, and then you start switching over and use a command line so that you can become a super master ninja. But I think for a lot of other people who areâ Thatâs not their career goal. Thatâs not what theyâre doing. They just want to use the tool and they want to get it done. I think using a GUI is a really, really good way to go. And I do recommend Git Tower. Theyâve been a sponsor of the show a couple of times. But they havenât been a sponsor because they were sponsor. They became a sponsor because I asked them to sponsor [laughs] because I love them so much and I really have learned so much from this tool. I wanted to talk about it on the show and they were gracious enough to sponsor past shows. Theyâre not sponsoring today. Weâre just talking about them because I love them. Thereâs also Github for Mac, which is free and it also works really â surprise, surprise â really, really well with Github. Itâs not asâ I havenât used it personally very much because I got, I kind of got my flow down with Git Tower and stuck with it, but one of the things I feel like Github for Mac and some of the other tools, some of the other GUIs Iâve seen are a bit moreâ Some, some you feel like developers designed them in a way that makes sense for the developer brain, and then others seem like designers designed them in ways that seem to make sense to the designer brain. So I think what probably makes sense for you if youâre shopping around for a GUI is to sort of try several of them and figure out which one fits better with your brain in the way that things make sense for you and, you know, take theâ keep the one that seems most natural. I like Git Tower because it does doâ Like, it does submodual support. You can totally do crazy, crazy stuff like submoduals without really worrying about whether or not youâre doing them correctly because it just handles everything. It handles stashes really nicely. You can see whatâs going on with your remote. One thing thatâs cool about these GUIs is that youâve got, like, thereâs this big tab that says âCommitsâ right in the middle of the Git Tower window, and I can see the graph that we were talking about, with this line and the dots and the branches right there, along with a list of dates and people and the messages for each commit and the hash or the giant long hexidecimal number.
John You know, I said I use command line, but I actually I cheat quite often when Iâm looking at the log. Iâll open up a GUI app to look at the log because itâs just way more easy to figure out whatâs going on. You can see these, you know, the branch diverging into separate branches and then merging back together, and you can get a text description of all of that stuff, but man seeing it visually with little lines going all over the place just makes it really easy for me to figure out whatâs going on.
Jen Itâs faster. Yeah.
John Yeah.
Jen Yeah. I can imagine that kind of workflow where youâre sort ofâ the stuff you do constantly is just quick-quick, bang it out on the command line, but the more complicated stuffâ I like, I likeâ One thing I like about GUIs is they feel safer to me, like itâs going to help me through this [laughs]âŠ
John Mmm-hmm.
Jen âŠand itâs going to remind me about things that I need to do that I wouldnât have remembered, or I can go ahead and try. I can risk some stuff and just click some buttons and try some kind ofâ I know what Iâmâ I know I sort of have the mental model but not completely. I think I know what Iâm doing, but Iâm not sure. I can just take like a risk because it will stop me if Iâm not doing it correctly, where the command line is a bit more powerful and a bit more willing to go, âReally?! Alright! Letâs do it!â [laughs] You know, like instead of where the GUIâs like, âNoooo! Donât do that!â [laughs] And I appreciate that as somebody who has not put Git mastery on my list of things to do yet. And I say that like I donât know what Iâm doing, but actually I know Git really, really well. I just know it from a functional point of view. I donât really know it from a I want to be the person everyone turns to when the Git repo melts point of view. There are people who do that and I love them, but Iâm not going to be one of them. So merge conflicts. So, a merge conflict happens when a merge is attempted. For example, Iâve worked locally. Iâve made a bunch of commits. Iâve made a bunch of changes. Johnâs worked somewhere else. He made a bunch of changes. He made a bunch of commits. And Iâve pulled his changes and I have committed mine and the Git locally on my machine starts to merge them together. And maybe thereâs 10 files, and nine of the 10 files merge together just fine, and that tenth file has a conflict.
John Yeah, Git is basically not able to figure out how to cleanly get your changes and my changes together into one file. And it goes, âUhh! Sorry.â
Jen And usually this happens when, like, if weâre writing CSS and I wrote some stuff on the top and you wrote some stuff on the bottom, itâs going to merge it just fine. But if we both changed the exact same thing in the middle and Iâm like, âI want the margin toââ, you know, the margin was 1 em and I want it to be 4 ems and you want it to be 3 ems, Gitâs like, âWell, what do you want people? Uh, this doesnât match.â
John Yep.
Jen And thatâsâ I mean, the merge conflicts are the most scary situation I think that happens most often because it feels like you can end up in a place where youâre just clicking around, typing around, and you just donât really know what to do.
John Well, itâs definitely a scary because, you know, a lot of the GUI apps make it seem slightly scary because itâs got this very helpful âAbortâ button, [laughs] which I would think would induce a lot of panic in people. [both laugh] Like, âOh no! Itâs an abort!â [both continue laughing]
Jen Why would I need that? Ahhh!
John Yeah, exactly.
Jen Yeah, and I think the earlier GUI tools didnât really have much in the way that was very helpful, where the later ones have gotten better and better. Like, I know in Git Tower thereâs actually a place where you can configure which GUI toolâ Like, there are merge conflict tools out there, right? So I use one, I always forget the name, but then Iâ Itâs, itâs like, âWait, what TV show does it sound like? DeltaWalker!â [laughs] Sounds like DeltaWalker, I donât know, like John Wayne should be in the tool or something because itâ Itâs a big file comparison tool, where Iâll be like, âLet me show you this file on the left, and let me show you this file on the right, and you can just scroll and see line by line exactly whatâs different between the two.â So, like, you can tell some of these GUIs âHey, I have a tool for comparing files. Please open these over there and let me go over there and change over there.â But then also Iâve started to find tools where you can just kind of click around and basically youâre trying to tell itâ Youâre trying to go line by line and say, âOkay, for line 62 I want you to use my copy. For line 75 I want you go use Johnâs copy. For line 83 I want you to use Johnâs. For line 91 I want you to use mine.â So itâs always like, âYours or theirs? Which one do you want me to use?â The other thing you can do is just open the file up in a text editor, because whatâs happened I think, I think â correct me if this is wrong â but I think what happens is Gitâ Oh, now Iâm confusing Git and SVN. But it marks the file up.
John It does. Yes. They both do that I think. But yeah, Git does. It marks the file up. Itâll put, like, less-than signs: <<<<<, like eight times and then itâll throw out some Git sort of magic [laughs] text. Itâll say like HEAD, and then itâll describeâ On the next line itâll describe, like, the one change, and then itâll put a whole bunch of equal signs, and then itâll describe the other change, the other version, and then a whole bunch of greater-than signs, right? [laughs] So you can sort of see that oh this is area where you got this conflict, and you can literally just, like, pick the line that you want to use and then delete all the other lines.
Jen And is thatâ Do you think thatâs how most command line jockeys handle the situation?
John I hope not, but I bet some of them do. Yes. And so basically you would just need to, like, search the file for a boatload of equal signs, right?
Jen [laughs]
John I think seven. So Iâm sure thereâs some command line jockeys who just, like, âOh, I have to go and search files for seven equal signs.â So it looks like Larry does that in the command line, err in the chatroom. He says he does it that way.
Jen Yeah. I donât know how other people do it. I just know the way I do it, which is Git Tower pops up some yellow,âŠ
John Mmm-hmm.
Jen âŠand I look at the yellow, and I click the buttons that say âThemâ, âMeâ, âThemâ, âMeâ, or itâs probably âUsâ, âThemâ, âUsâ, âThemâ. And then thereâs another button, and I click the button and I cross my fingers. [laughs] I mean, it sounds very non-technical but it is a bit of art, just the box, dark box. Like, I donât know whatâs going on, but I just need to clickity click click and thenâ But over time it seems less and less traumatic. Like over time it seems less and less of a big deal. Just be like, âWhatever, I want you to do this one and that one and not this one. Okay, go.â
John Yeah. So the funny thing is when Iâ the way I do merge conflicts is since Iâm on a Mac Iâve got Appleâs Developer Tools and buried somewhere in there is a little utility that will show two files, you know, next to each other and allow you to see the differences and then merge those differences in another sort of window below those two that are next to each other. So itâs like got three panes. So on the top you have your stuff on the left and their stuff on the right, and then below is like okay how do you want to combine these, and thatâsâ Itâs this little app, and I donât know what itâs called but it gets installed when I install Developer Tools. And then the Git command line, like, magically knows that this thing exists because itâs Apple and I donât know how that works exactly. So thereâs from the command line Iâm trying to do a Git merge tool. Iâll tell it, âHey, I want to use a utility to merge this conflict and fix this conflict.â Itâll say, âOh okay,â and itâll list a whole bunch of crazy command line tools that Iâve never used, and say âDo you want to use one of these?â and I go, âYes?â [both laugh] And then suddenly it opens up this GUI thatâs from Mac Developer Tools. So thatâs the way I do it. [both laugh]
Jen So itâs different but similar. Youâre not quite sure what youâre doing but you click around.
John Yes.
Jen I mean, you whatever around until you justâ Yeah. I mean, the idea is it has a problem. It marksâ It opens up the file and it marksâ
John It allows you to see your changeâ your version and their version,âŠ
Jen Yeah.
John âŠand you need to basically manually decide, because sometimes youâveâ Like, somebodyâs corrected a typo, like a missing comma or something, right? And you edited the lines a different way, right? So you just need to like look at the two changes and go, âOh, I see how itâs different thanââ and just sort of manually fix it.
Jen I feel like thereâs also thereâs a, you know, what itâs asking you to do is to look at the file and manually merge them together. Itâs notâ It hasnât deleted anything. Itâs kept everything there. Itâs marked which one is yours. Itâs marked which one is âtheirsâ and which could be from any number of different people. Itâs just not you. Itâs all the people who are not you. And what it wants you to do is erase all of those equal signs and erase all of those greater-than and less-than signs and kind of get rid of all the extra notation and just leave it with the one thing that you want. But, sometimes that can be tricky. Sometimes youâre not sure how to get that done. So, another way to get out of that problem is to just delete the whole thing. Like, just tell it, âI donât know what I did. Fine. Just do theirs. All of it. Them. Justâ Iâll redo my work. I donâtââ Because thatâs where I end up feeling like with any of these version control systems. I always want this magic fairy button that just says I donât know. Donât erase or change anyone elseâs work because I donât know what they did and I donât want to make anybody else upset. I donât want to undo anybody elseâs work. If you need to get rid of my stuff, just do it. I donât care. Do it. [laughs] Makeâ Make it work. Get me back to a place where I can actually keep going and if I have to redo my work thatâs fine. Go. But sometimes in the middle of a merge conflict, Iâll end up with that choice where itâs just like instead of picking through the file you can just say just keep themâ their file, everything just them and just get rid of my work and Iâll fix it later.
John Yeah. Thatâs oneâ Especially if the change is very significant â usually it isnât â but if the change is very significant, yeah Iâll like⊠Yeah, sometimes itâs just easier to just redo your work and say, âOkay, use theirs. Use theirs and Iâll edit the files again.â And thatâs sort of like the last resort.
Jen Or sometimesâ Yeah. Yeah, it is. Orâ But sometimes Iâll know that â and this happens more often early on, it happens less and less often I think the more Iâve learned about Git the less often Iâm confused, I just actually know whatâs going on â but theâ but at first it seemed like there are plenty of times where I kind of knew that I hadnât done anything useful. Whatever was going on in my local copy was just me messing around trying to, like, open the project, set things up, and I didnât want anything to be kept. I just wanted to get back to the way everybody else has it, which you can do by just delete the entire repo and reclone again. But that wasnât always the right answer. But yeah, somehow sometimes it was like, âI donât know! Just get me out of here!â Because the thing is with a merge conflict is you do have to do something about it. You cannot just leave it there. And you canât just leave it there like overnight and come back two days later. Like, you really need to go ahead and take care of it and get out of that state and then push whatever youâve done back to wherever everything lives and so that everybody else can keep going and work. I think it seems to me just from my gut that if you sort of ignore it and come back a week later or something itâs just going to be worse. Thereâs a good chance that everybody else has moved on without you and then the merge conflict is going to be that much more complicated down the road.
John Yeah. A good command lineâ Err, sorry. A good GUI tool definitely is a good way to go for merge conflicts in my, my opinion.
Jen Yeah. Yeah. And, and somehow like donât be scared. You can do it. [laughs]
John Like, if Iâ Itâs going to be different in every command lineâ Ah! I keep saying command line. [laughs] Itâs going to be different in every GUI.
Jen Every GUI. Yeah.
John Right. But Iâm looking on Git Tower, which Iâm testing it right now, I purposely created a merge conflict and basically it shows like a little yellowâ no, more like a yellowish tan bar across the top.
Jen Yeah.
John Thereâs a little yield sign with an exclamation on it after you try to do a pull, right? And then thereâs like a âShow Detailsâ button there, and you just click on that and it says, âSolve Conflictsâ, and itâŠ
Jen Yep.
John âŠlists all of the files that are in conflict. And if you click on each of those files, itâll show you, like, the lines like this is your version and this is their version.
Jen Yep.
John Which do you want to keep, and you just like have toâ
Jen Itâs a little pull-down menu.
John Yeah.
Jen And you just say them, me,âŠ
John Yep.
Jen âŠthem, me. Yeah. Yeah. I love that yellow toolbar, and when because sometimes it goes away. Like, sometimes I click on the wrong thing and Iâm like, âOoo! Whereâd it go?! [laughs] Give me the yellowâ Like, whereââ And as soon as I can find it Iâm like, âOkay, good. Iâm good to go.â Like, Iâll from here know how to get through this. Yeah. I mean, itâs not as hard as Iâm making it sound. Itâsâ Yeah. Itâs way easier than SVN. So, thereâs a couple things that sometimes I find helpful about understanding how a Git repo works. One is that if you leave your command line or your GUI tool, and you just go open up the thing in Finder, or really not Finder. Letâs say your code editor world â like I use Coda â and you look at a list of your files that are in your main directory, your whole project. Maybe itâs a website, maybe itâs something else. On the top level, in the first, you knowâ Maybe your directory is called project, and so at the top root level of the directory project, if youâ inside your tool, you make it show up all the invisible folders. Things can be invisible in Finder. You go open it up in Finder, youâre not going to see it because the stuff is invisible. But if you open it in some kind of tool that lets you see invisible files, it will let you see the invisible directory. And thereâs a directory called .git. What is it called? .git.
John No, thatâs it. .git.
Jen Just .git.
John Yeah.
Jen And all the information about Git is there.
John Yeah. I meanâ
Jen Your Git repo, I should say.
John Basically, you never actually have to go inside that directory.
Jen No.
John But that directory isâ It is that repository. So likeâŠ
Jen Yeah.
John âŠon, on your, on your local computer that .git folder is the entire repository.
Jen Yeah.
John And all the other files that you see are just basically your working area. Like, this is the most recent commit from the branch that youâre working on checked out to your working area and these are all the files that are all over your file system that you normally are editingâŠ
Jen Yeah.
John âŠin any tool you want, right?
Jen Yeah. Itâsâ
John .git is the actual repository, and then everything else is just your working area.
Jen Well and the idea that thereâs a parallel universe, this is the universe that youâre in, the other files. And if you go into your GUI tool or you use the command line and you change branches, then you can actually watch it in yourâ You know, I can open up Git Tower and switch branches, and meanwhile Iâm looking at Coda and the list of files in Coda and the files will like disappear and reappear and theyâre different because I just switched universes. I went from one universe to the other parallel universe. And if I open those files up, theyâre just magically the other ones, and I can save them, I can do whatever, and then I can switch branches and boom, I can be back into the other parallel universe,âŠ
John Yeah.
Jen âŠwhich is kind of freaky but it totally makes sense as well.
John Yeah. Well all the versions and all those different branches, parallel universes, all stored inside the .git directory.
Jen Yeah. And the reason
John And if you ever accidentally delete that .git directory, all youâre left with is the working files and like, the repositoryâs gone. You no longer have any Git repositoryâŠ
Jen Right.
John âŠif you accidentally delete that Git folder.
Jen And you donât want to do that by accident, but there might be a reason. You know, sometimes when Iâmâ Especially when Iâm sending something up or Iâm learning something and I just want to throw everything away and start over, you can just delete the .git folder, and if you do that then there is no more Git repo. It just goes away, and you can go reinitialize the Git repo and take those files and put them in a different Git repo from the beginning, kind of thing, if you need to for some reason.
John Iâve neverâ I almost never delete the .git folder, because itâs mostly when Iâve created a repository, Iâve started, like, adding some commits, and then I realize that gosh the work that Iâve just done is not really that useful for anybody else and not even that useful for me. [laughs] And like, Iâll rewrite it and throw away the old Git repository. And you create a new repository and make it look like I was, you know, smart from the get-go.
Jen [laughs] Right. Yeah, and I never, never, never, never delete it if itâs a real project that Iâm really working on, but if itâs some sort of a personal, experimental, half-baked, oh I screwed everything up again, when youâre in that kind of world, then sometimes you just want to get in there and rip it out. You can just make that go away. But the other file thatâs very helpful, thatâs right next to the .git file, err directory, is a file called .gitignore. Again, invisible. If you look in Finder, you will not see it. But if you look in a tool that letâs you look at invisible files, youâll see it right there: .gitignore. And that file is a place where you can list all the things that you want Git to ignore. So, for example, I use Sass, and Sass takes a lot of notes while it does things. The CSS preprocessor. And thereâs absolutely no reason for all those notes to be in the repository. Thereâs no reason that I need to share them with other people. They all get stashed, they get shoved into a invisible directory called .sass-cache. And I donât want the .sass-cache files in the repo, so in my .gitignore file, right up at the top, it says .sass-cache, and that means, âHello Git. When you find a directory any place (and frequently thereâs more than one in a project), if you find a directory with this name any place, just ignore it. Ignore it and ignore everything in it. Do not put this in the repo.â Iâll also have, like, .DS_Store which is a thing that the Finder shoves those little Finder files that shove everything all over the place. We donât need the .DS_Store files from the operating system of my Macintosh in the repo. That stuff needs to not be in the repo. Not everybody has a Macintosh. Like, go away. So, sometimes you need to edit this file. You can do so manually. You can also do so from the GUI. Like, when youâre in Tower, you see a file that youâre likeâ Like, the .sass-cache for example. The .sass-cache directory will show up in Tower as like, âHey, thereâs this directory. Do you want to add it to the repo?â and you can be like, âNo, I donâtâ and you right-click on it and you say something like please ignore this. Ignore this, ignore all things like this all the time, and it will take that note and put it in the .gitignore file. And then it will say, âHey, I changed the .gitignore file. Do you want me to commit that?â and you can be like, âYes, please,â because you want that Gitâ Sometimes you want this .gitignore file to be shared by the whole team so everybody has the file. Theyâre all sharing it around.
John Yeah. I use .gitignore quite a bit, especially like you said for that .sass-cache directory. And there are other times where it can be useful. You can use it like if you have aâ If youâre working on a project where like itâs a CMS project, because I work off and on Drupal sites, youâll have like one folder where as people upload stuff to the web server, it basically just stores all those assets, images, and stuff, Word documents and whatever, all in one directory. Like, the files directory, right? And if youâve got aâ If you get a copy of that from the server and put it on your local system just so you can have like a local duplicate of the real server for your development environment, you donât want to constantly see that folder thatâs not in your Git repository every single time you look at the list of things that have changed, right? So, because Git will always show you like on the command line you do git status itâll show you all the files that have changed and all the files that are not in your repository, because maybe you want to add them.
Jen Right.
John But if youâve got all this stuff that you donât want in the Git repository, itâs going to keep showing you all the stuff thatâs not in the Git repository that you donât ever want to add to the Git repository. And itâs just really annoying. Thatâs what the .gitignore file is for, is basically Git will pretend that that doesnât even exist anymore, and itâll never show you it as an option for something you can add to the repository.
Jen Yep. I frequently .gitignore Zen because Iâm working on a custom Drupal theme. Iâm not actually using Zen as a parent theme, but Iâm stealing code from Zen [laughs] I have a copy of Zen right next to my theme, and I donât want to put it in the repo because itâs not going to be used. It doesnât need to get delivered to the client, but I want it right there so I can look at it and steal code from it. [laughs] So Iâll just shove it in there, and then Iâll local .gitignore it so that it just sort of doesnât everâ The fact that Iâve .gitignored it, it doesnât even go into the repo. Itâs just locally itâs telling it, you know, âHey, this isâ This is something you should ignore and you donât even need to tell everybody else about it. Just keep it between us.â [laughs] And again, I do that from my GUI and I just right-click and I choose the choice that says, you know, locally .gitignore this. I donât know what the official command is or anything but itâs an option. Yeah. So, Iâm looking at some people sent in questions on Twitter earlier in the week when we were talking about this. Mr. Berger. Mr Berg-g-g askedâ said itâd be helpful for an overview of setting up local and server repos. Someone else asked about that too. Like workflow: local, remote. It feels like what people do is you putâ I mean, Git is software as well. Like, thereâs some Git software that you need on your computer. I believe if you do something like download Tower and install it, Tower will take care of this for you. If youâre doing it from the command line, you have to actually install Git on your computer. It doesnât come with a Mac operating system. I donât think it comes with Windows operating system. So if youâre setting up servers, you actually got to actually put Git on each of the servers, right? And then you can clone the repo into each of the servers. So maybe you have a development server and a testing server and a live server, and maybe theyâre three separate machines. You can just use the command line and as you set up the server just go ahead and install Git on all three, and then pull or originally clone and then pull those three. And thatâs where people will use branches and be like, âWe have a development branch. We have a live branch. And when weâre ready, weâll go ahead and merge whatever we want to out of development into the live branch and weâll keepâ You know, maybe the master branch will be our development branch. The live branch will be the special branch and whoeverâs in charge of the server for the live site will go in and pull whatever is in the live branch. Meanwhile, somewhere else, somebody has switched branches, gone to the live branch, merged in what they wanted, not merged in what they donât want, tested it, and then push all that up. You can set it up a lot of different ways. Different people set it up in completely different ways. I donât really have a lot of strong opinions about whatâs best. I think whatâs importantâŠ
John Wellâ
Jen âŠis for the team to sort of have a consistant idea of what theyâre going to do. ButâŠ
John Soâ
Jen âŠthe main idea is thereâs one repository, and everythingâs on one repository, and you just get to different places, different parallel universes on different machines. But itâs notâ
John Also, I would say that setting up a Git serverâ Git on server is certainly not an introductory [laughs]âŠ
Jen Yeah.
John âŠyou know, topic that people or, you know, designers who are just trying to figure out how to use Git. But thereâs some really good resources online. I actually wrote a blogpost. I had, like, hundreds and hundreds of Subversion repositories from, like, old clients and I just was sick of them and I wrote up a blogpost about converting Subversion to Git, and it does a straight conversion to Git. And so the next step after youâve converted from Subversion to Git is you want to put them someplace so that other people can access them, right? And Git is very flexible and thereâs like three or four different ways that you can set up a server and it all depends on the kind of access controls that you want to have. The easiest way is if you have a server that already has SSH on it. All you need to do is like ensure that Git is installed on the server, and you go and put the Git repository in whatâs called a bare repository format. And if you just put it on the server, basically anybody who can SSH to that server can SSH directly to that path to that Git repository, and that basically becomes sort of like the URL to this Git repository on the server. So like, your-SSH-username@servername: â which is just a regular SSH URL, that becomes the URL for accessing Git. And thatâs as far as Iâm going to go on the podcast to describe that because like I said thereâs good online resources. And I would say that, you know, at one time I thought about writing a book on Git, but the problem is that thereâs already like a really, really, really goodâ a really good book on Git already. Itâs fantastic, and itâs all online too. So it makes for like competing against that, stupid. [laughs] Soâ
Jen And what book is that?
John Itâs called Pro Git. Itâs by Scott Chacon, I think thatâs how to pronounce his last name. And if you just, like, Google âPro Gitââ Oops, I mistyped Git and I got a completely different thing. Wow! [laughs] If you just type âPro Gitâ, itâll show you that itâs git-scm.com/book, and itâs all online and thereâs actually a section on setting up servers. Itâs sectionâ chapter 4.4. So, you know, âGit on the Serverâ.
Jen Yeah.
John This is the book that I read to learn Git and itâs excellent.
Jen Thereâs also a way to tag. People use tags to kind of a different flag in the ground to sayâŠ
John Mmm-hmm.
Jen âŠthis is the moment where weâre going to release this code, whether itâs maybe a project that you end up saying, âOkay, now this isâŠâ
John Yeah.
Jen ââŠa moment. You can download this version. This is a good version to download.â
John Yeah. Well, if you rememberâ Tags are a really simple concept in that if you remember we talked about how each commit has a unique identifier which is that really long hexidecimal number, right? But then weâve got these sort of human-readable labels for our branches of development. So like, the master branch is basically a label that points at the most recent commit in this branch of development. And what a tag is, like itâs an additional label, right? So the master label is forâ The master branch label will continually follow the branch as itâs developed. Itâll sort of move to a new commit as you add new commits onto the master branch. So itâll just continually change places. Whereas a tag is a fixed spot. So you say, âI want to tag this commit with version 1.0,â and itâll remain there forever. You canât move a tag. Itâs like, âThis is the spot,â and itâll always be that commit. And thatâs all tag is. Itâs just a label that doesnât move.
Jen So transition in the chatroom is asking whatâs the best way to get started with Git? Say with a smaller project, maybe using Git for other type of files like Markdown files or something. Yeah I feel like, you know, we sort of talked about well a little bit, tiny bit about Github or weâve talked about, you know, how do you use Git at work. But I feel like if you were just wanting to get started and youâre sitting there yourself all by yourself, you donât have to have any sort of remote server repository or anything. I mean, thatâs kind of the beauty of Git. We were talking about just using Git on an airplane. You could say, you know, letâs say youâre using HTML and youâre using CSS and you want toâ youâre just going to prototype for a new website. Itâs not even really the whole website. Youâre working on a design. Youâre designing in code. Youâre just working by yourself on this thing. You could say, âOkay, well Iâve got this organized already. I haveâ I have a directory. Itâs called âMy Awesome Projectâ and in that directory Iâve got my index.html file. Iâve got a CSS directory. Iâve got everything all organized nice and neat.â You can take that directory and make a Git repoâ a Git repository out of that directory. And basically what youâre doing is youâre telling Git software, âHey, please come along, take this whole directory, make a Git repo out of it.â Basically telling it to create a .git, invisible .git, file folder directory and put that inside your project and start keeping track of everything, putting numbers, just giant hash tag numbers on things.
John And itâs incredibly easy. I mean, like, if youâre on the command line you just go to the root directory where you want the repository to be, and you just say git init and it creates a new repository with absolutely nothing in it. Like, no commits or anything. So you have to go and then add all the files that are in your subdirectories, right? And then commit it and make that first commit. And then youâve got a new repository locally. And then, like, Git Tower, thereâs like a repositories pull-down and you can manage your repositories. And inside that dialog box thereâs a section where thereâs like a little plus sign and it says, one of the options is âCreate New Local Repositoryâ and it does basically the same thing but with a GUI interface.
Jen Yep. Big giant button actually on the top right. âAdd Local Repositoryâ. Click! And then youâ
John Oh yeah! I didnât even see those. [laughs]
Jen Yep. And then thereâs a button, you browse, and you point it to the thing and then you hit theâ This where I end up making my first mistake everytime, is I alwaysâ Iâm never really sure whether I should point to the outside of the folder or whether I should get inside the folder. [laughs] And I always do it wrong, and then thatâs why Iâm deleting everything and going back and doing it a second time because itâs easy to sort of not know like am I supposed to be inside of the thing or am I supposed to be on the outside of the thing pointing at it. But yeah, you justâ So you initialize your local repository. And then you can use a Git GUI or the command line, and you can then open that project up inside weâll say GUI for a minute. Like, you open that project up in your GUI and then you start making changes to yourâ Well, first thing, right. The first thing you have to do is add all the files into the repository, and then as you make changes to those files you need to then either commit them or delete the changes, get rid of the changes. I mean, thatâs one kind of nice thing you can do is like, here I am. Iâm going along. Iâm making a whole bunch of changes. Iâve made a commit. I like this. Itâs done. Or itâs at a place where Iâm happy. Iâm going to go get some lunch. I come back from lunch. I try some new stuff. I made a mess. Like a real mess. So, Iâm just going to right-click on the mess and say get rid of this.
John [laughs]
Jen And then it goes away! And youâre back to where you were before you went to lunch. [laughs]
John Yeah. Definitely create a repository like a playground. You know, something you just mess around and try out different things. And thatâs a great way to learn Git. If youâre trying to learn Git on the command line, Jen and I were talking just the other day about try.github.com, which is aâ Itâs like a online tutorial for learning Git on the command line, but itâs really slick because itâsâ Each sort of lesson is shows a little command line on the webpage, but you can actually type real commands into this command line thatâs on the webpage. And it really works. Itâs really impressive.
Jen Yeah. This, yeah. try.github.com. Weâll put it also, the link, into the show notes. Itâs really impressive tutorial because itâsâ It basically stepping you step-by-step through how to make a repository, how to add files to that repository, how to make a commit, how to do each like each of these things that weâve been talking about in the abstract, walks you through them, all from the webpage. But rather than walking you through them by saying, âHereâs a screenshot of what it will look like. This is what you should type,â and then meanwhile youâve got to, like, go open up your own browser or your own terminal window, your own Finder on your own and do everything on your machine. You just do it right there because thereâs like a command line window embedded into the website page and itâs actually a real command line. You can do all kind of other crazy stuff on here too, if you know if youâ
John And thatâsâ Yeah. And thatâs absolutely the best way to learn is to actually do itâŠ
Jen To do it. Yeah.
John âŠwhile youâre like reading about it. And thatâs the nice thing about try.github.com is that you canât go on to the next lesson until you actually type in the thing that itâs trying to teach you.
Jen And I suggest this even for people who are very much learning the GUI route. Like, go check this out too because it will help you. You can learn a few things on the command line. It will reinforce the concepts. And in the end you end up with a Github repo. It like makes you a little Github repo [laughs] as you go through it. And then you can just play with Github.
John Yeah. One of the steps is learning about remote repositories. You know, because you got your local repository where youâre doing your local work and then the remote repository is where, you know, basically the server where everybody is collaborating together. And so the try.github.com, one of the steps is go and create a Github account. [laughs]
Jen Right.
John Quite clever on their part. [laughs]
Jen Githubâ We should talk about Github for a minute. I mean, it comesâŠ
John Yeah!
Jen âŠup all the time because itâs so centric to a lot of what a lot of people are doing, but I mean itâs really kind of amazing. It feels like a space on the Internet where anyone can join in. You can find piles of code that other people have created. You can grab a copy. So, for example, HTML5 Boilerplate is a really great sort of starter kit for front end development for HTML5 on the Web. Thereâs a zip file. You can just click a button and download the zip file, which is how you might want to grab the code if you do not want to have anything to do with Git. But even better, you can go over and get a copy. You can actually check thatâ You canât check the original repository out because that belongs to the people who own the HTML5 Boilerplate project. If you were to clone their repo, you would have all these permissions to be able to edit it and change the files and erase and delete things and add your own stuff and commit all that back. And if youâre one of the people who is working on HTML5 Boilerplate, then thatâs absolutely what you should be doing. But if youâre a stranger who just thinks that their project is cool, what Github has you do instead which is not really a Git thing â itâs more like a Github thing â which is that you can fork the project, which basically says, âHey, I like HTML5 Boilerplate. I would like to edit some of it and have my own version. I want to have a different, you know, I want to fork this project and Iâm going to make it HTML6 Boilerplate [laughs] and Iâm going to put some unicorn ponies into it.â And then you have your own copy, your own fork of it, and you can make all sorts of changes to your version. You clone it from the Github repository, the Github servers, and do all sorts of things locally and push all those things back up to the Github world. And then you can, because itâs a community and this is how it was set up, you could you know maybe you didnât destroy HTML5 Boilerplate. Maybe you found a bug and you want to fix that bug. You fork their copy â you have your own copy â you do what youâre doing, and then youâ Thereâs tools on Github to say, âHey fine folks who are in charge of HTML5 Boilerplate. I found this bug and I not only am going to tell you about it, but I actually already fixed it in my copy of this thing in my fork, so Iâm going to suggest that you take this commit that I made and merge it back into the original repo. If you like it, then here. Itâs fixed! You can have it.â And so people do that. They collaborate by actually having separate, completely separate forks of the same project so they donât have to know each other. You donât actually vet anybody or interview anybody orâ You can just kind of get a whole bunch of help from a bunch of strangers. And so thatâs I think why Github is so powerful and why so many different people are contributing to projects. Because a lot of those suggestions, a lot of those commits that people come up with are really amazing and you can get a lot of work done very quickly.
John Yeah. I mean the collaboration on Github isâ Thereâs a certain style of collaboration. There are different ways you can collaborate, but the collaboration style on Github is quite useful because, you know, youâ Like, you said youâve got this, the official repository for HTML5 Boilerplate like you said. So itâs got all of itâs commits there in perfectly open in the public, but only a couple people have commit access. They only have permissionsâ Only a few people have permission to make new commits on that repository, right? Because you donât want to allow everybody to make commits on that. It would just be crazy. So, the collaboration style on Github basically says, âYou know what you can do? You can fork it, which makes a complete new clone that you have access to and only you have access to. And then you can make changes to that and then you can notify the maintainers of HTML5 Boilerplate and say, âHey, go look at this change. I think you might like it.ââ And because both the original and the fork are, you know, publicly available on the Github servers, everybody can look at those, you know, to, you know, look at this new change and, you know, merge it back into the official repository. Whereas if you just cloned the original version onto your local machine, thereâs no way for the HTML5 Boilerplate maintainers to see your local computer, right? [laughs] So itâsâ Like, thereâs no way to collaborate in that sense. So thatâs the nice thing about forking is that youâre creating a public clone.
Jen Yeah. Yeah, and itâs a way to, you know, sort of Github gives you permission to mess with the code without actually having permission to mess with the real code. So if you wanted to be malicious or do something crazy, itâs no big deal. But if you want to do something really helpful, you can do it. And because itâs all right there and because itâs all a bunch of Git repos, that itâs actually quite easy as a maintainer of a project to field those requests and to say, âYou know what, Iâve got 15 requests yesterday. These two are really good. Clickity-click. Done.â You know, I donât have to copy and paste the code from a comment and test it and see and blah blah blah. I can just say, âYes Github! Please do merge this commit into my official repo that only I have access to, or me and my friends have access to, from this person who I just met.â Yeah, itâs called a pull request. So you can submit a pull request to somebody elseâs project. But it makes it really easy to collaborate on a project to say, âHey I found a bug,â or âI have a new idea about your thing,â or âYou know, I think you should also include this.â Itâs also a way to say, for example, maybe Normalize â the Normalize reset stylesheets â maybe I really love Normalize but I think it should be different in this particular way because Iâm a finicky front end developer and I have my opinion about something and I have a different opinion than Nathan does about how it should work. I want it to be my way. Well then I can just have my own and always use mine and, you know, just have it be different.
John Was that aâ Was that a leading question when you picked Normalize orâŠ?
Jen [laughs] Am Iâ No.
John Because I actually have a clone of NormalizeâŠ
Jen Yeah.
John âŠ[laughs] where I converted it to work better with Compass.
Jen Uh huh.
John So Sass and Compass. So itâs a Sass and Compass port of the plain.css file of Normalize.
Jen Oh nice. I should go use this. Yeah, see then I can use yoursâŠ
John Mmm-hmm.
Jen âŠbecause perhaps I use Sass and Compass and I want Normalize with Sass and Compass, so itâs publicly available. I can use yours. And then if something changes in Normalize, then you can say, âOh look, that new IE10 bugfix they just addedââ and you can just sort of merge that back into yours andâ
John And in fact, thatâs what just happened recently because version 2 of Normalize.css came out, which was great because itâ They tagged a 1.0 version, which says, you know, all these browsers are supported including IE6 and then they made some changes and committed a newâ They got rid of all the, like, IE6 and IE7 support because it was adding bloat to the code and made a sort of slimmer Normalize.css which they tagged as 2.0, and I had to merge those changes into my Sass and Compass port. And it was relatively straight forward because I just had to do like a merge.
Jen Yeah. Yeah, itâs kind of crazy because then you donâtâ Itâs not all this sort of manual laborious cutting and pasting and you would think that itâs not a big deal but it turns out that when things are easier youâre more likely to do them. [laughs]
John Mmm-hmm.
Jen And something that might take two days suddenly takes two hours, and youâre like, âAh thatâs not a big deal. Go ahead and do that. And now you know Iâll share it with the world. Oh yeah, let me see this thing right here.â So, I highly suggest people checking out Github, both for the just thereâs tremendous public things appear like HTML5 Boilerplate and Normalize and thereâs all kinds of libraries. I think thatâs what people know it best for is this is the place for all those libraries end up living. But then also itâs interesting like I can come into your page and check out all the different repositories that you have. I can see all the forks that youâve made from other peopleâs projects. I can fork yours and have my own copy of your copy of their copy. I can also see all the original projects that youâve created yourself.
John The only thing that I would wish that Github had was a way to differentiate between, like, the this is aâ Basically, like, have two levels of repositories for likeâ Because Iâve gotâŠ
Jen Ohhh.
John âŠwhat does it say there? I donât even know how many repositories I have on Github. Letâs say thereâs 15 of them, right? And most of those are just like throw away repositories, right? [laughs] Iâve forked a project because I canâtâ Basically Iâm creating like a bookmarkâŠ
Jen Right.
John âŠof a project. [laughs] So like FlexSlider, Iâve cloned, but I actually havenât made any changes. Itâs not really significant to look at my version of FlexSlider. In fact, my version of FlexSlider is almost assuredly out of date because I havenât merged recently, right?
Jen Yeah.
John So I wish there was a way to, like, say, âHey, these repositories are interesting and you should look at them.â
Jen Right.
John âThese other ones, theyâre just there. You can look at them if you want to.â
Jen Yeah, I was just messing around. I didnât really do anything useful.
John Yeah.
Jen Yeah. Yeah, itâs true. Itâs alsoâ
John But I guessâ I guess itâ But the nice thing I guess about Github is that it does sort of sort them in the order that youâve modified them. So I guess the cream sort of rises to the top and that Iâve, you know, Iâve actually made changes to this repository recently and hereâs the stuff at the top.
Jen Yeah.
John That helps a little.
Jen Iâm going toâ Iâm going to put yourâ You created something called compass-zen-grids and thereâs aâ Iâm going to put your network graph in here as an example of a graph. Because these graphs get kind of interesting because then you end up withâ You can see all the different people and all the different branches and, like, this person was working on a commit and then this person grabbed it and they were working on it and then it got merged back over here and merged back over there. Thatâs really how I learned Git is that I was working on things that were on Github and I would push my changes and I would go look at the graph, and Iâd be like, âDid that make the thing the way I wanted it to? [laughs] Uh, no. Okay, what did I do? Oh, thatâs not what I meant. Okay.â And then Iâd changeâ fix it, then Iâd go back and for awhile everytime I ever pushed a commit I would look at the graph to make sure it came out the way I wanted it to, until my mental model really built up, until I really understood what it was that I was doing, how it was that I was bundling files together in the particular commit, how it was that I was merging. Especially when it came to branches and really understanding, like, which branch am I on, which commits were on which branch, when I merge them back what happened, because thereâs a couple different ways you can sort of take a whole branch and mash it up in one commit and shove it on top of another branch or you can kind of take all the individual commits that you had all along and keep those commits as separate and put those as separate commits orâ Thereâs some fancier stuff, and I really found that looking at these graphs on Github helped me in a way that nothing else did to understand what I had or had not done. Understanding which commits were on which branch. Seeing what my collegues had done really quickly.
John Mmm-hmm.
Jen Yeah. You can also getâ You can pay Github some money and getâ and have a privateâ have the ability to create private repos. So I have, for example, I do this with all my clients and then Iâve got, you know, private repos for my clients so that their work is not public, but I get all the fancy tools and as I work on different projects freelance, lots of times thereâs not a ready system administrator and remote repository all set up. And theyâre like, âWhat should we do?â and Iâm like, âLetâs just use Github.â [laughs] Put everything on Github. And itâs very easy for all the people who are working on the project to just grab everything. They should sponsor. [both laugh] Yeah. Yeah, so I donât know if there are otherâ What else do we need to fill in the gaps? If people who are listening live want to toss your questions into the chatroom. One of the things we didnât talk about that we should talk aboutâ Gosh weâre over two hours now. I wonder if we should just wrap it up. I hope this is helpful. Thereâs some other links. An article on A List Apart Iâll put in the chat and the show notes. A tutorial on how to use the command line if youâre interested in learning the command line separate from Git issues but just in general. Like, thatâs another thing perhaps youâve been interested in learning. Thereâs some step-by-step tutorials that Iâve found that are really helpful, learning how toâ
John Maybeâ Maybe I can talk about remotes to try to do that quickly, remote repositories a little bit.
Jen Okay
John Because we talked about, like, the labels that we add to branches and, you know, the labels that we add to tags to make it sort of more human-friendly. We actually do the same thing for remote repositories, and when you do aâ like do a git clone of a repository thatâs on Github, thereâs like a URL. When you go to the project on Github, you can actually see the URL to clone the remote repository, and you sort of copy that and you paste it in your GUI client or whatever and you clone it. And what happens is that Git says, âYou know what? Youâre never going to remember that URL. [laughs] So Iâm just going to give it an easy to remember label. Iâm going to call it origin.â And so now youâve got this remote repository which Git is calling origin and itâs remembered this URL for you. And that sort of meta information of thisâ Itâs kind of like an address book actaully. So youâve got a list of remote repositories and by default youâve got like one thing in your address book, which is the name origin and then the actual URL for that remote repository. And a lot of times when you do git pull and git push, this sort of longform of that command on the command line is to actually specify which remote server you want to use. But Git knows that if you donât specify which remote server, itâs going to assume the origin. But you canâ
Jen And youâ
John You can addâ Go ahead.
Jen The use of the wordâ Sorry. The use of the word origin is just a habit, right? Itâs just a convention.
John Yep.
Jen You could name it frogs if you wanted to.
John Mmm-hmm.
Jen It just happens to be that people say letâs have one official remote repository and letâs call it origin, just âcuz.
John Well, itâsâ Itâsâ Itâsâ
Jen Right? Or is that wrong?
John Yeah, itâs a convention definitely, but itâs a convention thatâs sort of enforced by the code inside Git. So when you do a Git clone, it doesnât ask you what you want to call this, this remote computer. It justâŠ
Jen It just does.
John âŠcalls it origin, right. And you can, you can change the name later if you want to. Thatâs easy. Butâ
Jen Youâre confusing everybody if you do, but. Yeah.
John Right. It calls it origin by default.
Jen But you could have more than one remote. I mean, youâre only going to clone fromâ I mean, you can only clone once, so youâre only going to clone from one place. But my understanding of Git is that it is by convention that we sort of say, âThis was the official computer. This is the computer thatâs on all night and all day. This is the compuer that never goes offline. So letâs call that one the official one and weâll just all clone from that one.â And Github is a great place to do that. Or thereâs others. You know, thereâs other services that you can pay or you can set up a server somewhere.
John Beanstalk and Bitbucket, yeah.
Jen Yeah, Beanstalk andâ But you donât have to do that. I mean, it could just be that thereâs six people and youâre working on a super, super secret project and you donât want it anywhere except on your six laptops and, you know, good luck making sure that people are online at the same time [laughs] and so you can push and pull, because if somebodyâs offline then you canât push or pull to their computer. You canâtâ I mean, it feels like you could name any one of those asâ You could clone fromâ Maybe this is totally wrong, butâ
John Yeah. Iâ Noâ Iâve used remote repositories as a way to like help colleagues who are running into Git problems. So, like, Iâll doâ Iâll set up a Git remote, Iâll tell Git to add a new remote thatâs like Larryâs. This never happens with Larry. Larryâs pretty good with Git. But pretend that Larryâs hit his head under the table and now heâs forgotten what the heckâs going on, right? So I set up aâ I add a new remote, which on the command line is like git add remote and then I want to give it a label, so Iâll call it larry and then the actual URL to his laptop, right? And weâre all sort of in the Internet here, err Intranet, inside our office andâ
Jen In the bunker. In the bunker. [laughs]
John Yeah, in the bunker. And I specify, like, maybe itâs the IP address to his computer. I donât know what it is. Some way that I can connect to his laptop inside the bunker, and Iâll use that URL. And then since Iâve labelled it as larry, I donât have to remember that god-awful IP address or whatever it was, right? And then I can do fetches and pulls and pushes. And what Iâll do as far as, like, trying to debugâ When Iâm trying to like help somebody and like debug whatâs going on in their repository, Iâll do a fetch. So Iâll basically copy all of their commits from their remoteâ from their repository, and so that I have a copy of it locally. And then Git allows me to see what does their verison look like because itâll actually sort of label, like, you know, this is your local copy and this is their copy, and I can go and look and see what their copy looks like, and then try to help them figure out whatâs going on, right? Because sometimes I can, like, try to do a merge locally to sort of emulate whatâs happening if theyâre in a merge conflict, you know, on their laptop. So itâs a, yeah. [laughs] Maybe that got a bit too complicated. [laughs]
Jen Yeah. I mean, this is the stuff that like you donât have to understand this part at all.
John Butâ Butâ Yeah. The bottom line is that you can setâ You can add additional remote addresses to your address book. So Iâve got this larry remote address and Iâve got the origin which is Github, you know, and you can have Git, you know, push or pull to all of these different remote repositories and do really unusual sort of collaborative techniques. Thatâs sort of the basic point I was trying to make.
Jen Yeah, because maybe your Github is the official one and so thatâs where everything, you know, somebody else started it out there. Or maybe you started it out. Maybe you set something up locally, you created the repo out of nothing locally, you added the original six files, and then you go over to Github and you push everything to Github. And so now thereâs a repository on Github, andâ Or you could do it the other way. You could go to Github, click some buttons, create a repository on Github that has nothing in it, and then clone it from Github to your own computer. But either way, letâs say youâre the person who created it, then youâve put it on Github, and then you got six people on your team and they all pull it from Github or clone it I should say. Clone it from Github. But then, meanwhile, you have a dev computer or development computer where youâre going to put stuff. You know, and maybe you want to set that up as another remote. Or maybe you wantâ You know, thereâs all sorts ofâ It feels like thereâs all sorts of kinds of ways to do it and I donât think that most people who are using Git need to understand any of this, but I almost feel like, almost, that itâs sort of helpful to have a vague, confused sense that itâs possible just so that you understand sometimes when youâre using the tools that youâre using, like why itâs as complicated as it is. Like, âWhy is there an option here for origin or something else. Like, I donât need that. I always use origin. Why is thereââ Well, because sometimes you might want to have something else there and thatâs why it has to be set up that way, because you configure it another way.
John Yeah.
Jen But yeah, you donât have to really understand that stuff if you donât want to.
John Yeah. And if youâve got multiple remotes on the command line, you can do, like, git remote -v which will list all of the labels and all of the URLs for your remote repositories. Oh! And thereâs one thing that I forgot about command line that I always say when Iâm trying to teach people how to use Git on command line, is that --help is your best friend. So like, git remote --help will tell you all about the remote command, you know, how to use it, right? So, git add --help will tell you all about the add command, you know. Use --help all the time. I frequently, and I really mean this, frequently forget some of the, like, switches that I need to use for likeâ Like, you can rename branches to be something else. Like, say you accidently put a typo and, you know, instead of âversion 2â you put âversoin 2â, right? You can rename the branchâ I donât remember how to do that, so I do git branch --help and it tells me, because it gives you help text.
Jen Thatâs cool. Yeah, and so I think thatâs it. I hope this was helpful to people. Itâs aâ I think itâs challenging to figure out how to explain things for someone whoâs not started at all and also explain things so that people whoâve been doing it for awhile but are still a little kind of confused can also get something worthy out of it. So, I hope we somehow hit the right sweet spot for you. Yeah. Thanks, John!
John Yeah, Iâve given sessions with like last all day trying to teach people Git, so you can just keep going and going and learning new stuff, so. Hopefully this is a relatively good intro.
Jen Yeah, I mean I kind of feel like the bottom line for me is yes, [laughs] Git is really great. It will save you over and over again. It can really help you get out of a jam when youâve written code that you didnât like, when you canât find the Photoshop file that you had last week, like youâ It can really help you and save you, and it really does make sharing work much, much, much easier. I wouldnât want to have to do it any other way. I mean, I canât imagine trying to use something like Dropbox for CSS. Like, itâs just ridiculous. Youâve got to use a version control system. Out of all of the options out there, you know, perhaps Mercurial or something wasâ would have been just as good. I feel like that because so many people are using Git and because of something like Github, itâs emerged as the tool, so go with everybody else, you know? Go learn the tool that everybody else is using. Andâ
John Thatâ Thatâs absolutely what, like, what Drupal.org did because there were a lot of people inside the Drupal community who were using Bazaar and really liked it, and in the end we decided that you know thereâs actually a lot more people everywhere using Git. So when went and switched away from CVS, we chose Git because of that, because of everybodyâs using it. And itâs really paid off because the GUI tools that have develped for Git, because more people are using it, means that thereâs more opportunities for people who donât want to use a command line to use those. And if we had decided to use Bazaar we would be basically forcing everybody to use the command line and oof, that would not be so good. So.
Jen Yeah.
John Git is a great option.
Jen Yeah. And I doâ I really do feel like designers and business people and content people and product owner people can jump in with this. I mean, there are tools out there that can make this easy enough so that youâre using a GUI and youâre committing your Excel spreadsheets and your OmniGraffle files and your Photoshop files and your HTML and your CSS and your Word documents, all into one repository. And whatever your job is on that team, that you contribute what youâre contributing and other people contribute what theyâre contributing and everybody can share all the stuff. And ask your colleagues, I mean ask your colleagues who are much moreâ who are more code nerds than you are for help and just keep going. It feels like one of those things that when you first start using it, youâre like, âOhhh!â and then if you just keep going it willâ That feeling will wear off and youâll totally get it. And just like all the other computer tools, like learning the mouse and the Finder and saving in the first place, it will start to make sense and you can totally master it to the point where youâre able to use the tool to get the stuff and to push the stuff and thatâs really all you need. Somebody else can set up the remote repositories and the servers and stuff. Yep. Thatâs my end of the lesson today. So thank you JohnâŠ
John Thanks Jen.
Jen âŠso much for being on. And thanks to The In Control Conference for sponsoring. You can follow this show on Twitter, @thewebahead. You can follow me on Twitter and on App.net as @jensimmons. John, youâre on Twitter asâ Youâre johnalbin everywhere?
John Yep. Yeah, github.com/johnalbin, twitter.com/johnalbin. Yes.
Jen And youâre also at albin.net.
John Yep.
Jen And you have a couple articles about Git that I tossed into the show notes. And if peopleâ It would be really great for people to go rate the show and review the show in iTunes, The Web Ahead. I think the new iTunes is about to come out. It should be, and as people are starting to surf around the new software and check out the store yet again, it would be really awesome if theyâ if the show is at the top of some of those lists as far as, you know, whatâs hot and whatâs popular and all that stuff. So, you can really help out the show by going over and rating it, writing a review. I read all of those reviews. They really do mean quite a lot to me. So if youâre enjoying the show, if youâre getting something out of the show, Iâd really appreciate if if you could go over there to iTunes if you havenât already and write us a note. Write us a review.
John Is next week going to be a Web Behind episode?
Jen Next week is a Web Behind episode and then the week after that Iâm having a guest on to talk about IE10. Whatâs up with IE10, because it will be out and weâll need to know whatâs up.
John Awesome.
Jen So yeah, tune back in and look at the schedule at 5by5.tv/schedule to see when it is that weâre recording the shows, and you can join us live. I think thatâs it. I think thatâs all the pieces that I have to say at the end, so thatâs it! Listen later! Talk to you later! Bye!
John Bye!