 It just turns out that RStudio is a very convenient client for For learning RGit, but I've lost my, for some reason, I've lost my my slide presentation Where did it go? Why is it not showing up? I'll get it back. Let's do it over here Slides. R is a really convenient way to learn Git Also because it's It's integrated into R. It makes it easier to teach but there are lots of Git clients Some of which are free and some of which cost money and so we'll talk a little bit about those The main things we're going to try and learn today are really we're going to use Git Our goal is to create a reproducible document So this is all couched in this concept of reproducibility We want to be able to generate things that people can look at the history of what we've done and see transparently what we're doing so that we can we can present that to other people But so in order to do that we're going to make a Reproducible document and that's going to allow us to learn several the aspects of Git the one the main things that We're going to try and learn today are these commands right here add commit branch Merge and revert. We're also definitely going to do push, pull, and clone And the fork and collaborate will leave off until part two I think I talked about most of all that already So I talked a little bit yeah, we're going to use our studio right basically because it's free But let me just mention these three clients that are listed here and I'm going to show you a resource in a minute You can everything I'm doing Is hanging off of this URL right here our fund at library.duke.edu so you can take that back But so blind merge is actually a client that I literally just learned about I think Monday morning And I like it because it's free for everybody You actually have to pay for it Well, you don't have to sort of on the honor system pay for it pay for it If you're going to use it and what you pay for is three years worth of software upgrades But even after the three years you can continue to use it. You just don't get the upgrades And given how good it's so stable. I don't actually think there are many upgrades But it's a free evaluation copy so we can all use it today if you're a student here I recommend looking into this tool called git kraken Get kraken costs. They do a monthly subscription. You can't pay just once So it's like seven bucks a month Which I personally think is outrageous not worth the money although it's probably the best git client out there But the reason why I mention is because if you're a student And you have a github account you can sign up for this thing called the student pack and the student pack comes with all these free things And one of the free things is unlimited private repositories at github And one of the free things is free access to git kraken So as long as you're a student here That might be a nice little side benefit Although you'll learn that we're going to try and focus on some of the command line aspects of git All of these gooey tools make it a little easier to move around Git in general is very command line driven and I think by the nature of it can be a little Hard to sort of make us to understand as a second nature tool because really It's it operates just a little bit above the operating system level. It's always in the background It's not something that you're Thinking through to produce your projects. So these gooey tools can be nice But you still have to understand the command line in order to really do them. We'll mention this one other tool Source tree which is actually free and The caveat behind that Is that by default it works with this Competitor to github a product called bit bucket It will work with github, but you have to do more configuration And here's the thing about so there's that's part two we're talking about github git lab and bit bucket The thing about get is that We're my goal here today aside from making a reproducible document is that you come away being able to use get on your laptop because gets Initial configuration in my opinion is a real pain in the butt So we're going to try and move you beyond that because it's pretty much a one-time only Aspect and you can get really stuck in all these weird Unix commands and some of these weird operating system level issues once you get beyond that And you're doing the basic get operations the push the pull the clone the merge all that but I'm going to step back one more point the reason why we're doing this at all Get is for version control and we'll talk about what version control is in a minute, but Um Version control is very very handy for being creating reproducible science right or reproducible projects I just want to point out this guy right here Carl Brohman Has some very accessible blog posts on steps towards reproducible research, and I highly recommend them We're going to kind of focus on this one aspect although That version control down here But the reason why we're doing any of this at all I mentioned already get crack and I mentioned merge Sublime merge reason why we're going to do it in our studio is it really enables all of this do everything with a script Make all of your code reproducible all of those reproducible aspects are priorities for our studio So it works very very well The central aspect of this point is a do everything with a strip so that it can be run So that it's not prone to all these little weird some tactical point-and-click things that you might do like the point here is Except things like Excel are not nearly as reproducible as a tool like are because most of everything that you do in Excel It's a very nice tool. It's a graphical environment You can you know copy and paste whole sections, but you can't script copy and paste right? You can't it's very hard to document that if someone wants to know How did you move this table from this worksheet over to that worksheet you have to write some really sort of? Painstaking instructions in order to explain how you transform that data So you do these things in a script to avoid that to enable yourself to essentially Have a reproducible document All right from a thousand feet up. This is what we're not going to get into this too much But this is sort of what version control looks like On your file system using git any folder Can be a git repository a repository? You're really just a folder or a directory and the collection of documents in it And so it makes it really easy to share because if I have a repo or repository on my file system Let's say it's this right here We'll get back to that in a minute Technically would be more like this right here if I have that and I want you to be able to run all of that code on Your system I can just email it to you or if I put it up at github you can pull it down I can either put it up in the cloud or I can send it to you electronically It's just a folder that contains all of my work. It may contain my data my scripts My images and my table output all of those kinds of things so These each one of these Repositories represents a stamp in time as I've changed my workflow right it's still the same directory It's just representing a different stamp in time So this is where the clone pull push all that kind of stuff comes in but really all the intellectual work is Happening in this case right here in the middle right my project itself has nothing to do with git right? So I'm editing. I'm composing. I'm analyzing in my case or in our case today. We're doing this all in our studio But we can use git for any application on your system because it's related to the folder on your system So as long as the dispendent dependencies all exist in that folder that Repository can be shipped out to anybody and they can reproduce it on their workstation But effectively this is what we're going to focus on right so I Have a local repository or a local folder on my workstation Anytime I make a change to that I add the change in the file system Into a staging area You're going to try to make this a little clearer in a second and as I get a series of changes then I'll commit that into the version history So I'm writing My the storyline of how I did my project as I go along and then as often as I want to I'll push that up to a remote Repository and so in this case my remote repository is going to be github and it's going to be a public repository You may have reasons why you want to do private repositories again students can do unlimited private repositories at github If you're not a student there are different options for you for private repositories But just know that at github if you're not a student you're kind of limited to I think it's three maybe five Maybe seven private repositories and after that you have to pay for the privilege of making them private But in the spirit of reproducibility and open science we're focused on the public Repositories which and we'll see why a minute In any case I've made all my changes think of it this way like I work on two different computers I work on a computer here at work, and then I'll go home. Sometimes I work at home So the way this essentially works. This is my local repository or my work laptop and make all my changes I commit my changes all day long and Periodically during the day. I'm pushing that up to github Five o'clock comes by the last thing I'm going to do is do a commit and a push to make sure I've gotten all my work Up into that repository to go home walk the dog eat dinner or whatever and maybe I have this sort of Inspiration while I'm doing not work and I go oh wait a minute everything. I did after one o'clock is wrong, right? How do I roll back? Well each one of those commits is a step in time So I go home and I pull from the public repository which was the last it's up to date the last thing I did at five o'clock as I push and I come home and I pull that down onto in this case a different computer They can imagine another repository over here a different computer. That's also set up with git And I have all of that version and I can roll back to any step or I can look back at any step Or if I don't have to roll back I can keep on working and keep committing Keep adding keep pushing push it back up to the public repository when I get back to work tomorrow morning I do a pull and I bring my work computer back up to the exact same state So not only do I do that with myself where I am my own collaborator But I can share that with anybody I want I can tell my boss, you know have a look at the repository and see what I did last night and One of the really nice things that we'll talk about Particularly next time is that it really once you put it into those repositories that are up in the cloud It really enables collaboration so that you can have two people coding or analyzing on the same data or Another thing that's really kind of cool is that every public repository anyway If I had some really neat data analysis that I was doing I was super pleased with it And I made it public and I blog post and tweet and all that kind of stuff And somebody else who's smarter than me comes along and looks at it and goes oh, this could be a lot better, right? So they can by the spirit of it being on github. They can actually fork my repository fork Being completely separate copy and make all the changes they want At which point and because I'm being open I'm assuming that they will give me credit for what I've done, right? I have a license that I can put in there So they can say hey, I did all this work and it's built on John's work Which is cool or they can improve it and they can send me an evaluation and say hey Could could you pull this into your workflow? Do you like what I'm doing and so once you put that stuff up in these social coding networks? You enable collaboration with a whole vast world that you didn't necessarily Anticipate and it could lead into very fruitful things All right, so getting down to our studio. I should ask how many folks have used our studio before Alright great almost everybody. So you'll know and we're gonna start using it up in this upper Let's see upper upper right hand quadrant of our studio There's a tab all the way over on the right, and I realize this is a little hard to see This little tab says get and what our studio has done is they put the major get commands right into this bar So the commit the push the pull This is how you do branching but again if you go back to Every folder on your system is a repository Then if you make a change You have to use this command in a normal setting get add file name. So if I had a file called to do dot text and I had a list of things I wanted to do and I add one I save it the mere fact that I modified that file Makes it eligible to add it into my staging area So in the old days of get or in the traditional days of get I'm gonna have to type out get add To do dot text and that would add it into the staging area And in our studio context or with a lot of get buoys I can just click this button and that adds it that adds it into the staging area So anything that has a check mark here is staged to be committed and then To write my version history. I would type get commit dash M and say I just added to the to-do file or I just spell checked my whole project or you know, whatever you want to say In a you know, our studio context you just push press the commit button and you put in your message Spell checked project on this day and then You click push so that's sort of the whole of it And what I'm going to suggest is I think I Don't think I need to talk more. Oh one other thing. I'm one other point. I want to make We're going to work in with basically text files only But as I mentioned a get repository is just a a folder on your a directory on your file system Anything you put in there is eligible to have be under version control. So it can be pictures. It can be data It can be Microsoft Word files. It can be Excel files. It really doesn't matter It doesn't have to be our studio or our things. It doesn't have to be text files Just in case you haven't seen this before we're going to be working in this context called markdown and Markdown is a way to give structure to your ASCII document so that when you Render it to somebody the structure has some visual qualities and some structural qualities What I mean by that is if you proceed your word with a single hashtag mark it would be a heading Major heading which is not displayed here if you proceed it with two hashtag marks would be a subheading So you can start to see how this plays out in other words italicized words are wrapped in asterisks bold words are wrapped with double asterisks If you're going to do a bulleted list you could say bulleted list and then proceed each list item with a dash or a numbered list you can make I Don't think I have it here You can make URL links if they're relevant to your context So we're going to use this Markdown technique in our reproducible document. It's very simple to learn. It's very sensible But don't let it worry you Okay, let's just dive in here. So here's what I want to do I Want you to go to our fund library.duke.edu slash get on your computer and That should bring you to this page and I sent out a note asking people to do some prerequisites Which was to install our studio are and get and also to generate some SSH keys So my question to you is how many folks got the three applications installed? Okay, great and the SSH keys Good audience. I like you guys a lot. This makes my life a whole lot simpler We may Let's see if we can skip the Let's see if we can skirt through the SSH key part We're going to try and figure out right now how far along we've gotten what I would like you to do if you could is open up our studio and You'll see this kind of an application this For quadrant application again to get part is really up here But it's related to your file system, which is down here And I want to be in this terminal part right here, which is in the bottom left and what I'd like you to do is Let's see under overview under home where yeah under prerequisite Okay, so if you click on overview and Scroll down you could click on this sidebar where it says generate SSH keys in advance of workshop And all I need to know this we want to stay together here. So if you're not with me Shout out. Okay. Let's go slow. Let's go a little slower So what I want you to be is our fund library dot Duke dot e you clicking on overview When you get there, just give me a little nod Oh, it might not be there yet. That's okay. That's okay. I'm glad you brought that up No, it's okay it miraculously miraculously appears when you after you set the folder to be a git repository So we'll accomplish that I'm so glad you brought that up. I have to remember to tell people don't worry if you don't see that but here's what I want you to do down at step five and translate if you're on a macro windows, I want you to pick up the right command but Actually, I might have this somewhere else. I think up at step. Yeah step two Get this command right here at step two that that is a Unix command It reads cat space till the forward slash dot SSH forward slash ID underscore RSA dot pump Now go back over to your R studio and paste that into the console and When you do that That's not the oh, I made a mistake you don't want to be in the console You want to be in the terminal? Okay? So the difference being The console is command line activity for R and the terminal is a nice little Unix window which Is really handy even though I mean it's Unix like commands even though you're on the windows or a Mac It allows you access to insert Unix like commands, which is basically how git works So right there in that console. I want to I Want to paste in my command Now if you're having trouble pasting on a windows machine shift insert might help you yes, sir Yeah, this won't hurt anything this particular command won't hurt anything. Thanks for asking What I'm trying to determine is if you type that and press enter Do you see something like this and if you don't see this kind of? Just string of weird text. That's what we want to make sure we get everybody in the same spot the command is again is cat space tilde forward slash Dot SSH forward slash ID underscore RSA dot pub So anybody not have that Okay, good, right then we can we can go oh that's interesting Let's have a look at that The only thing is that you you gave yours a name instead of hard instead of ID underscore RSA yours Yeah, I assume you did this. Did you do this just the other day? That's old, okay, so Well my question to you is do you have any sense that you're I mean I don't want to mess up an existing infrastructure No, okay, so all you need to do is Actually, thank you can I think you can do this anyway. You just have to if you could Anywhere where anywhere where it says ID underscore RSA you just want to you just want to substitute that This is like real typical Get configurations. Okay All right, so if we have that and it looks like everybody does then Let's make sure that we have this now Set up on our github. So what I want you to do is open up a new browser tab and log in to github Okay, and I'm going to do the same thing I'm actually already logged into github My github looks a little bit like this yours Probably doesn't have that horrible picture But what we're going to do is we're going to We're going to go to the settings and add our SSH key So clicking on this Down arrow scroll down to where it says settings And you should then have this screen and we want to go this tab over here on the left hand side that says SSH and GPG keys and Then you should see something that looks like this I have a whole set of keys already exist in existence You may have none or you may have one depending on how far along you got if you already pasted in your key from last time I'm necessarily have to do all this, but I'm pretty certain you're gonna do you have pretty certain you don't have any keys That's my guess. Okay, so Let's free at least for you and me. We're going to go back to our studio and That command that I tick typed into yours Let's see. I need to put in you need I need to put in clip. I think and you need to put in pipe PB copy. So where I have I Have something like this you're gonna have something similar Tell me when you get there and if you need anything And all I'm doing there is copying my buffer That so in terms of keys there are two keys. There's a public Dot pub and then there's a private key private key Just like you wouldn't like leave your own keys on a table and walk away from them You don't want to share that around It's not so sensitive that you have to be concerned that someone's going to hack your computer That's not really the issue. You're just you know, if someone says hey, let me have your private key You say no, okay? The public key you can share with anybody really doesn't matter and we're going to go put it up at github right now You need to have a set of keys on every Computer that you intend to interact with github. So those prerequisite steps that I documented there You can do that again and again and again So every time you go to a new computer. We've now cut we've copied that public key into our buffer We're going to go to back to github and over here we're going to click add a new SSH key and Right here under key. We're just going to paste that in So it should look exactly like this or well not exactly, but very similar And the email address that's in there should be the same email address you used To create the github account Now I'm going to give my key a name. I'm going to call it Delete me soon get rid of this but you might call it something more useful like shoot You know like my my favorite laptop or who knows what something to that effect. Hi, yeah, yeah Okay See if I did this right new SSH key. I thought I just did this but it didn't seem to shoot Key is already in use. Oh, that's fine. Mine says key is already in use so I can look at that All right, so now I have my keys up there Now We're going to go back to here All right Now what I want to do is I want to go over to this thing says hands-on So if you can go back to the our fund library dot-duke dot-duke slash get page and Click on hands-on. There's a sub menu there Click on a knit clone push and pull so In knit is a git command that's typically run locally on the local file system. It simply says make my local Directory a git Repository and it runs a bunch of stuff in the background But there's a couple steps that I like to do up at github first because it just simplifies life Yeah We can work on that after after the workshop if you want Okay Right, so there are some commands that are easier to do up at github That a knit step in particular So we're just going to follow this script here and we are going to create our repository first Up in github If I could get my computer to work I Would be really pleased all right, so How do I do that over here? I'm going to go to github.com And I'm already logged in And so what I want to do now is I want to Click in the upper right-hand quadrant. I want to click the new repository button Right, so there's three icons up here. There's one that has a plus If you click on that you can choose new repository And so we're just going to invert the process a little bit and start by making our repository up at github Rather than typing get a knit down locally first and then we're going to give it a name So I'm going to call this test one It's it's a good idea to stick to those really Strict naming conventions at this stage, you know like no spaces or weird characters You don't absolutely have to but I would recommend it you can give it a description my first github repository and We're going to as you see we're going to make it public And let me scroll down here a little bit Go ahead and click this initialize this repository with a read me file Couple other things we're going to do since we're working in our We're going to start with a get ignore file What a get ignore file does is it says there are certain files that we don't need to push back and forth Into the repository all the time and in this case because we're working in our studio They're just a couple little our studio files that don't have any real bearing on our project They don't have any bearing on transferring things to other people who are doing the same our stuff So we're going to ignore those files. So you click on this where it says none and you get a drop-down list So there's a whole set of ready-made ignore files depending on your application if I type the letter r It will allow me to choose r and then you'll see the ones below that r. Oh s rails But I just literally want the one that's r And so now this little button will say get add dot get ignore are And then next to that there's an ad license This is what I always do here if you click on the ad license type MIT License and select that now just a real quick comment on license The MIT license basically says hey anybody who wants to share this go ahead and share it, but please Attribute me Right. I think it says that I'd have to read the license to be sure. Do you know? Yeah, please attribute me and it also says no warranties right if you take my code and you run it on your Workstation and your workstation blows up. It's not my problem, right? That's those are good good things to say My personal there's lots you can get really into these licenses. There's lots of different licenses I kind of prefer creative commons licenses But the MIT one is is a very popular license for software and particularly for software development If you're doing data analysis, you might want to use a different one All you have to do it's just going to generate a license dot txt file if you want if you want to use a different license You just copy that as a straight ASCII file paste it over top of the MIT license. It'll be fine This is a great way to start. So I've got these I've I've selected my read me. I've given some names I've selected my dot get ignore r and my MIT license and I'm going to click create repository the green button And then I'm going to get This is my repository up in the world for all to see it's called test one and it already has three files And if you haven't looked at github before It automatically displays the read me file with whatever structure you've given it. Okay So as I mentioned, we're sort of skipping the get in it step Are so our step to now that we've created this file is we're going to clone it down locally. All right, so I'm going to click this clone or download button and Just by way of mentioning functionality if you click download zip or you had some friend click download zip They'd be able to get your whole get repository without doing any of the steps We just did which might be relevant. Maybe they're not doing any development. They just want to see the work, right? But we're going beyond that so we want to get this actual get the dress right here and You'll notice right here It says use HTTPS and if you click on that it'll toggle back and forth between use SSH and Use HTTPS so you actually want to click on it when it says use SSH so that It's then the negative toggle right it allows you to toggle back to HTTPS Because you want this address right here To look that way and now that address is primed and ready to work with your SSH key So if you just click on this little clipboard button right here, you'll automatically save that into your buffer and Then we're going to go back to our R studio All right, so click on our studio or open our studio and If you haven't used our studio before I know this could be a little Unsettling perhaps on at least disorienting But everything in our studio is designed to work Sort of similarly to a repository right repository is a folder in our studio every project can be a folder So we're just going to link those two up together I'm going to make a new project and to do that. I'm going to go up here in this upper right hand corner There's a little drop-down and I'll get a subcontext menu that says new project So I'm going to click new project and When I do I'll get this dialogue box up here and one of the options will say version control That's the option I want the other two options just so you know if I had doing a brand new R Project and I had nothing to do with get start here under new directory If I had a directory already on my local file system that I wanted to bring into R Would use that But this is for the git repo that I just developed the version control one. So I'm going to click on that Version control and then there are two more options. I can use git or I can use subversion. They're similar I personally have never used subversion. So I can't say anything about it But you have options and you can use both just not both in the same directory and Now I get this new dialogue box window and in this first Sex box right here. I want to paste that git repo address that I copied a Moment ago. Let me show you where it came from just just to remind you This your address right here that I copied is going to go right here Okay, I Have the option then to browse through my local file system and put this repo Anywhere I want but I'm going to take the defaults in my case. It's going to put it Inside of the windows users documents directory I'm going to click create project and Then and now I'm wondering did you all get that? Oh good This git could these initial steps of git can be so frustrating that sometimes I forget where the stumbling blocks are Good. So what are we done? We've brought down license read me and get ignore and our studio put test one dot project up there and Any one of those that we want to look at for example, if we click on read me It will put the read me file Up here in the upper left-hand corner Okay So what I want to do now. Oh And you should also now have if you didn't have it before you should now have a git tab Right yay Git tab and if you click on that, you'll see something very interesting What this is telling us is that we can now stage two files we can stage Get ignore which is telling us it's been modified This only happens once I'm not really sure why but it's fine and we can stage test one dot our project which is a particular Small file unique to our studio Let's just ignore that it only happens once and it's fine never hurts anything Let's go through the process of using git We want to right now all it's telling us is these two files changed and we want to add those into our repository so we're going to click on the checkboxes that are right next to it and You'll notice that the icon in this one case this changes to a for an end and we want above that is an M for modified I'm pretty no a for add an M for modified So right now we've staged two files the next thing we're going to do is commit so click commit and We're going to give our commit a name So in this upper right-hand box where it says commit message we're going to type I Don't know. Let's call it my first commit Because it really doesn't matter we can get it is Probably the art of using version control well is putting in good Interesting commit messages that are short and brief that explain the context of what you've just staged but The reality of putting in commit messages is you have a lot of spell check this made a typo there Fixed a URL done. It's fine. You don't have to get overly stressed out about your commit messages It's just something that speaks to you and helps you understand the history of your project so I put in my commit message and I'm going to click this button right here that says commit and Then we have this error message Which you can all fix but basically it says I don't like how I have Identity doesn't like how I've identified myself And it tells me that if I run this command right here, I can fix my identity so that I don't get this error message We're just going to ignore that that error message doesn't hurt anything but up at the top You'll see there's my first commit it says who committed it. That's me and Then it says my name and email address were configured somehow strangely the other thing it says up here at the very top That's the command. I just execute get commit dash F Whatever it's helpful to realize these commands exist and are reflected back to you Even if you don't always understand them the more you use get the more that that Reporting will be useful to you it also tells us that we Modified to you two files with 14 insertions even though we really did nothing. It's again of just an initial stage Let's click close here, and then the last thing we're going to do is we're going to click push and Push is going to push all those changes back up to The public github repository Okay, and so Mine said master master, but I'm betting yours doesn't I'm betting yours once Actually, maybe once a password or something like that Okay, so what that means is your SSH keys Worked exactly as designed What it did is it allowed your R studio and your local file system to communicate with github in a secure channel And you could modify your repository so now let's That's that initial one. We just get that out of the way. Let's actually modify a file Right, so if we close all those and you go back to your R studio And open up this read me file which looks like this it has a Hashtag space test one which says it's an upper-level heading and then it says my first github repository So what I want to recommend is let's let's a put a blank line in there between those two Just for the sake of putting it in there and rather than test one. Let's call it read me All right, and then down here below it may be line six let's just Let's put it a second level heading to hashtags and say I don't know favorite colors and below favorite colors we're going to put a bullet point and you can put in any colors you want and So then each one of these colors that you put there is just preceded by a bullet point The point is we just want to make a document here And when I'm done with that I'm going to click save and What you will see will happen when you have saved is that read me will show up again over here in the working directory Because the read me file has just changed and so get is giving you an option to decide Do you want to stage this add it commit it to history or not, right? Now there's a step by a book about how you can back out right now go. I don't want to do that, right? I'm pretty certain actually that it is Right there But let's just say that we knew what we were doing. Okay, because it's less confusing that way We do want to add it. So we want to stage it and to stage it We're going to click on that checkbox just like we did before and You'll notice that at this point you can check and uncheck as many files as you want right and Then when it's checked and staged I'm going to click commit again And I'll show you a bit more. It's interesting One is it tells me shows me how my file has changed, right? So line one of the old file or the old version of the file was hashtag test one Like one of the new version and everything in green is the new stuff is Hashtag read me then I added a blank line and it tells me that here Lines two and lines three changed still says my first get hub repository But it's just a different line and then everything down here in the green is all new stuff So I can I can look at that and see what the difference is. You'll notice No, sorry, I'm not going to say that right now Okay, so I'm going to put in a commit message and I'm going to say first first edit to read me and click commit and Again, I get this funky error message, but if you scroll all the way up to the top You see that again you get the get commit message there and all the way down at the bottom It tells you what you just committed one file change And it says nine insertions because it's effectively nine lines of the document that have changed so I'm going to close that and then I'm going to click push So a couple things can happen here. We can look at the history of our commits locally But it's probably a little bit more fun to go back over to GitHub And when you when you get to your GitHub repository, you'll notice that this is still the prior version Because we haven't refreshed our GitHub repository. So if you just refresh this page This will instantly when you do refresh turn over to the modified read me file that we had before So it has my it has some it has effectively been rendered as Markdown, right? So this is a top-level heading. This is a second-level heading. This is standard text. There's a list But more importantly with respect to git Is it tells us we've done three commits our version has been tracked We've done three versions of this file so far you can quibble with the numbers because me in my mind it's really just one but Let's have a look at it click on those commits And it'll tell me every step along the way What I had I did my initial commit. I did my first commit and then I did my first edit of read me right at any point if I want to go back and look at What the files look like at that stage in a commit I can do that It depends on what you look at right now and we probably don't need to get into it too much But the reason why this is important and the reason why it's useful to put things up into github as well as having a local version Under version control is that github is way easier to investigate your history You can investigate your history of your local file system repository, but you're going to spend all kinds of time in command line Can we call command line hell? It you know, just you're just really going to get mired in the way git works Versus if you have even a public or a private repository You can use Github's natural features to go back and investigate what you had done before and so if you needed to pick out just one Little line that you knew you had done. It's just way easier to do it at the github section So for example, if I let's say I don't I've changed my mind. I had just changed The top-level heading test one to read me and now I'm going. No, I really like that I liked it better when it was test one But maybe I can't remember exactly how I spelled it right so I know that it's under this first commit I Can click either this button or this button and I can look at how the file was That's not the one I want But that's this is real life actually you end up you end up kind of investigating and then I can look at how things changed And right here it tells me what the file looked like before so I could just copy it or I can Click on that little thing there and it will give me all of the files from that version You can investigate this to your hearts to light but It's the point is it's just a much easier way. There it is right there There's the test one It's just a much easier way to investigate the changes and so you can copy and paste stuff at that point If you need to make some updates All right 959 exactly Well, we got a little ways in and I promised an hour and I don't want to I Don't want to Go much beyond that but we have haven't gotten as far as I'd hoped See how far we got we did cloning We brought down a local repository we did a push and edit and commit and we did a pull So That means that next time if you sign up for next time we'll talk more about branching emerging and reverting But let me just talk briefly about branching because it's really really handy So the idea of branching is this very this local repository that you have let's say you've gotten everything just right It's exactly how you want it now you want to do a variation and you don't want to mess up what you've already got So you can branch your repository and call it Maybe the first in this case the first one's called master get ahead always calls the default one master But if I wanted to branch it Let's say I could call this proposal one And I would do that by clicking on that little icon right there and just naming proposal one and click create and then what gets going to do and it shows me these commands right there is it Created the branch and checked out the branch and it pushed the branch up to github and then it switched So now right here it says proposal one and now I can do any changes to this I want It's in the exact same directory But depending on which branch I have checked out. That's the view I'm going to see and So I can make all kinds of changes to proposal one and at the end I can dump it Or I can make changes to proposal one and I can go Oh, I really like some of this stuff I want to merge that back into into the master branch and that's another thing that I can do So branching is really handy, but we don't really have time to get into it more. We'll cover that in part two we will also cover collaborating with other people and We will cover reverting back into our history Yeah, so I took the full hour But are there questions that you that are want to try and ask right now, or do you want to be released or? heck, I could stay here for another hour actually, but Yeah, so if you want to go back to one of the previous versions What's yeah? Okay, that's a great question The answer is kind of complicated There there get commands called revert and reset where you can You can find that previous history actually, let me see if I can Go over here and show you I'll show you a different get client and this is a different repository, but if I scroll down here, you'll see this This little it's actually doesn't display very well. Sorry about that. Let me see if I can make the screen a little better Yeah, you'll see this sort of visual representation and the pink is my master branch And the orange is a branch that I made where I was doing stuff and then I merged it back in and your question Is how do I get back to a different version? Each one of these dots is a commit? It's a point in time and if I wanted to go back The easiest way to do it would be to get one of these clients and just you just pick it and then you Then you go over here and you choose Is it this one? It's this one or avert commit Okay, but When I do that, I'm rolling back three Like I may be don't really wonder. I'm you know, you have to be very careful when you roll back in time Like literally time travel is always You know one has to be careful If there's just one file that you want There's this xkcd comic comic Comic strip one frame. This is a joke, but this is really really true like another thing to do is To just copy your whole is because every git repository is just a directory Like move it somewhere else on your file system and call it You know old or or safe copy or whatever and then go and clone a New version of your repository and pick out the files you want some of this we're going to get into next time, but I wait we will have enough time next time It is something that you have to be careful about and if you want to get a jump on it what I would suggest to you is This That section right there will talk about reverting back one step, but it won't talk about reverting back multiple steps And then the other thing that thing that happens to be more often than not and it sort of depends on your workflow is that it's Usually that I don't really want to do a whole bunch of rollbacks It's just something in a previous version that I've some little bit and that's when I go to github and I started investigating the commit history right which looks like I Go in here that commit history And I'll start investigating Different versions of the commit at the time because it's a whole lot easier at github to comb through the visual Representation of the history, and then I'll just copy and paste out something that I want So there's different ways to do it. All right. Well, I appreciate your attention As I've said this can be procedurally confusing, but hopefully you are all I know not all of you are able to but most of you are able to do a Commit and a push on a public repository If you need to do more private repositories than your staff, let me just note to you that OIT runs their own Public social coding site was not public. It's Duke only social coding site Get lab dot o it dot Duke dot edu and you can put in all the private repositories you want But github is like the you know It's the big press the Facebook of social coding sites It's a really good place to build a portfolio Especially anything you want to have public Any repository that you have on your local system can be pushed out to multiple social coding sites So you don't we'll talk about some of that next time. That's where you deal with these things called remotes