 Hey, folks, I just got a great question on an earlier episode of Code Club. In that episode of Code Club, I was starting a brand new project and I was creating the project from a GitHub repository. In other videos, we've also created new projects from within our studio. And then the question remains, as Jamie B. Han asks, I'm sorry, Jamie, if I'm mispronouncing your last name, what would you suggest doing if I already have an existing R project that I was working with, that I want to tie to Git? It seems that the only options of new directory, existing directory, and version control are useful if you want to create a new project. But I'm not looking to create a new project. You know, who else has an existing project that's not tied to GitHub? This guy. We're going to cover that in today's episode of Code Club. So yeah, we've been working for a few weeks now on this data from Ipsos. And I haven't been connecting it to GitHub at all. If you've been wanting to get the code, I've said, you know, go to the link down below in the description, take you to a blog post for today's episode, there you can get the code and the data. I've been doing that because frankly, I feel like it's a little bit easier for most people that are new to R. If you're new to R, well, GitHub might just be a little bit too much. Anyway, I think this is a good opportunity to answer Jamie's question. And then for the rest of you, or you know, perhaps now if you're a little bit more comfortable with our think about how you could then go in and work more with GitHub inversion control. And it's a great tool for making your code and your data and your deliverables, your figures and whatnot, more publicly accessible. And that's always a win. So again, we have in our project root directory here, we've got our vaccination attitudes.rproj file. I've got my CSV file. And then I've got my chart R my Ipsos and my makeover versions of our code, as well as the TIFF files that we've been generating. But this is not under any kind of version control. If I look in the upper right panel, there's nothing here that says get nothing that indicates version control. So to be able to connect what we're doing here in our studio to version control, you need to have get installed. And I've covered that in that other episode where if you've got Mac, it's pretty easy to get get to be max typically come with version control. If you're using the Linux subsystem on Windows 10, it should be fairly straightforward to get get there as well. So I'm going to assume that you can figure out how to install get on your computer. And so I'm going to be working within our studio in GitHub to connect the two. So I guess you'll also need an account on GitHub. So I can show you where you can do that here in a few moments. What we'll do is we'll go into tools. And in here, I will then do a version control project setup. This then brings me to my project options panel and your version control system it might be set to none. But you want it to be set to get. And so you'll then say yes. Yes, you want to restart our studio and we'll go through a little bit of rigmarole here. And now what you'll see in the upper right corner here is a tab for get. And so now we have effectively initiated a get repository in our project. So if you're used to doing things from the command line, this would be the same thing as doing get init period. It's like my favorite command in all the world because it means we're starting a new project. Well, we've been running a project. So anyway, what I can now do is I can go ahead and stage all of these files. Normally, again, you'd be modifying just a small number of files and then committing them. So we need to do that initial commit. So we can go ahead and stage these here. Then click that commit button. And now I can enter a commit message. So I'll say initial commit for ipsos data project. Go ahead and commit that it's committed and everything is good and up to date. We no longer see anything in our get panel. And so everything is fresh and up to date in GitHub, you're going to need to create your own account if you haven't already. And, you know, these sites make it really easy for you to sign up. If you're if you're doing everything in public, it's free for you to use. If you want to have private repositories and you're not in academia, then it's going to cost you something each month to have private repositories. If you email GitHub and tell them that you are at a university or a nonprofit, they will then enable your account to have a certain number of private repositories. Actually, I think it's an infinite number of private repositories if you're an academic. I have this project that we've been working through Riffamonus. I also have my personal account. My lab also has its own account. And so again, that's a whole nother subject, but your lab should have its own account. So I'm going to go ahead and create a new repository. And again, the owner will be Riffamonus, but you should be the owner of yours as well. And so here I'm going to go ahead and put in vaccination underscore attitudes. And that is my repository name. And so these are the files associated with the Riffamonus analysis of Ipsos vaccination attitude data. All right, I want to make it public because I want you all to be able to see it. And I'm going to skip all this stuff for now. I'm not going to add a readme file. I'm not going to add a gitignore. My local repository on my computer already has a gitignore file. And later on, I can add a license. So I'm going to go ahead and do create repository. And so now it tells me what to do. Isn't that wonderful? And so I have an existing repository already. So I want these three commands. I'm going to go ahead and click this copy icon. And then I'm going to come to my terminal tab. If you don't have a terminal tab, you can get that by going tool, terminal, new terminal, right? And so this has me in my project working directory vaccination attitudes. You probably don't have this master here. Don't worry. It's just a little bit of flourish that I have for mine. And then I'm going to I'm going to do a paste to paste in those three commands, hit enter to make sure they all run and get some output here. Everything should be good. Now if I come back to Safari and hit refresh, voila. I now have all of my files here in GitHub. You'll see my gitignore file. I don't have a readme file. So that might be something that I would like to do as well as creating a license. So to show you the process of how I would update the repository by adding these files, I'm going to come back to our studio and I'm going to create a new file. And it's going to be a mark down file. And I will save this as readme.md. And so I'll put two pound signs for a second level heading and say readme. And I'll say repository for code club episodes related to ipsos COVID acceptance, COVID vaccine acceptance data. Okay. And I'll just leave it there. It doesn't have to be anything too crazy. So we'll go ahead and save that. And so now what you'll see in my git tab over on the upper right corner is that I have modified readme or it actually exists at noticed. So I'll go ahead and stage that. And then I can commit it. And then I'll say created readme file. And then I will commit that and close all this stuff. And so now that is committed. If I actually come back to this commit, I can go ahead and push that up to GitHub. And so again, if I refresh this, I now see that I have that readme file. Actually, now that I noticed, I think it gave me a little dialogue here at the bottom of my window offering to give me a readme file. So I'm going to come to the creative commons website. And they've got some HTML that I can grab to go ahead and insert into my readme file. So I'll go ahead and copy this. You can get this if you search for creative commons CCBY. And this should give me a little icon that I can put into my readme file. I'll go ahead and put that right here, save that. And then obviously, we have modified our readme file. I'll go ahead and stage that and commit it. And put in my commit message. Now, I wouldn't necessarily be doing a push after every commit. Again, I just wanted to go through a few reps of this process, if you're not familiar with Git and GitHub. So I'll say add CCBY license. And what this license does is it allows you anybody to use the code, the materials that are in here, as long as you hopefully give me some type of attribution. And so I'll go ahead and commit that, close it. And then again, we can push it up to GitHub, and then come back to our GitHub refresh. And now we see we've got that badge, as well as the work is licensed under the Creative Commons Attribution 4.0 International License. So that's in there. So more importantly, we've demonstrated how you can take an existing RStudio project, and push that up to GitHub. Again, a little bit of a hitch is that you do have to do some work in the command line, where you're taking the commands that GitHub gives you to connect your local repository to the remote, the GitHub version of the repository. You also need to have Git installed on your local computer, and you also need to have a count up on GitHub. There are other vendors besides GitHub, like BitBucket, I think, and Subversion and other things. But I find that GitHub is wonderful for serving our needs, and is just really useful. And again, I cannot emphasize enough that it'd be wonderful if your research group had its own repository, so that when you publish a paper, you can link back to that analysis, that repository that has the analysis that was done in the paper, so that people don't have to contact you personally by email to get information from you. They can go directly to the link in your paper, and that is a win for research reproducibility. All right, go off, create your own GitHub repository and link your projects up to GitHub. And we'll talk to you next time for another episode of Cat Club.