Transcript#
This transcript was generated automatically and may contain errors.
Welcome back to the Data Science Lab. I'm Libby. I run community here at Posit. I am joined by Isabella Velรกsquez. Isabella, would you like to say hello?
Yeah. Hi, everyone. Good to see you.
I am also. Yeah, we're also joined by Isabelle today, special guest. Isabelle, you want to say hey?
Hello. And I also have, if you let me, Toast is also joining.
Yes. I'm such a Toast fan. You guys have no idea. So today, Isabella and I are going to be your leaders here, and we are going to be talking about collaborating in GitHub using Positron, and our framing for this will be we'll be working together on a Quarto book.
So Isabella is going to get us started. She is going to share her screen, and we are going to be really going from nothing here. Like we're going to start a brand new project, brand new repo, and the point of today will not to be a step-by-step tutorial on how to collaborate in GitHub. The point of today is to show you what's possible in Positron in this VS Code ecosystem. If you are used to being in RStudio, and maybe if you're like me and maybe a little bit like Isabella, you might be like, you know what? I'm used to get in RStudio. It's fine. I don't need to learn the new things in Positron. I used to feel that way, and I don't anymore, and I just really want to share what you can do.
If you are a VS Code professional who is like, I collaborate in GitHub all the time with VS Code, and there's more that we're missing, just give that context in the chat and help people learn. We can't cover everything today, and that's on purpose. All right, everybody.
Creating a Quarto book project in Positron
Here I am. This is what my Positron looks like when I first open it. As Libby mentioned, really for pretty much everything that we're doing today, there are multiple ways that we could do it. We're just going to be showing one particular way, and then, of course, you can always adapt your workflow to whatever you need. Since we are working on a Quarto book, so a Quarto book is a special kind of project from Quarto that links together chapters and documents and things like that, and you can add references, things like that.
Again, multiple ways of doing it, but how we're going to start is I'm going to open up the command palette, which in Positron is Command-Shift-P, and then you'll see I have various options. Because I've done it recently, the Quarto create project is at the very top. I'm going to click that and then open up a book project. That's going to pop open my directory, so I usually put my R-based projects in this RRR folder. This is the folder in which the Quarto book folder will be created. I'm going to choose this as my project directory, and then I'm going to call it a name. This will be the name of my Quarto book project. I'm going to call it Diaz Lab Quarto Book. You can see here it's saved within RRR on my computer.
Press Enter, and here we go. Now I'm inside my Quarto book folder, and you can see that here on the left-hand side, I have all the files populated to create a Quarto book. A very basic book would have several documents like this index.qmd and intro, references, and then also this underscore Quarto.yaml file, which basically lets us know this is in fact a book, as you can see here in line two, type book, and then you can add metadata for your book, continue adding pages and whatnot, and from there build out your book.
We have the files, which is great, and we can see this is a preface with this is a Quarto book and things like that. If we want to actually take a look at what the book would look like, we can hit this Preview button up top, and this will preview our book. Here in the terminal, we can see that it rendered everything, and then if I open up this viewer, here indeed is the book. Here again is the preface, the introduction. I can pop it out here into a new browser as well if I want to.
Initializing a Git repository and creating a .gitignore
But since we're talking about Git today, you may notice if you have used Git before, there's nothing here that lets Positron know I'm working with Git at all. Here in what's called the primary sidebar, there's this GitHub item, and if I click that, oh, I'm sorry, not there yet, the source control item, there's going to be two options. I can initialize repository or publish to GitHub. If I click Initialize Repository, it does exactly that. It'll let it know that indeed I want to use Git within this folder. And in here, this is going to showcase all the things that have changed. Because the folder was empty before, and now it has all of these files, which lets me know there are 30 of them. Those are the things, the documents that have changed that I can push up to GitHub.
Yeah. So I'm going to create a .gitignore file. And so what this does is it creates a file that basically tells Git what to ignore. So if there's anything that I don't want to push up to GitHub, because it's a giant file or because it has some secret or something like that, I can put it in here. And so I will let it know I don't want, for example, my Quarto folder, which is here, to get pushed up to Git. And then I'm also going to say I don't want the book folder, which is here, to get pushed up to Git. And the reason for that is I think it depends how you want to work together, but all of these are generated every time somebody renders something. And the more files and things like that, the more likely you might run into conflicts and things like that. So if I save this, you'll notice that the 30 files that were here in the source control are now eight. So basically because everything that is within these two folders is now being ignored by Git.
Authenticating with GitHub
Isabella, there's a question in the chat from Mike. Do you have to create a GitHub account before starting this kind of project? Yes, you do. And so down here, this lets you know I am already logged in to GitHub. And so if you haven't created a GitHub account, the first thing is to go to GitHub.com, create an account. And then when you come here, there's actually going to be an option for you to sign in from here. And then Positron will allow you to authenticate from here. Basically, it'll open up the GitHub in a browser, you put in this code, and when you come back to Positron, you'll be logged in.
Let me see if I can. Can I? Let's find out. And this is literally just to show you what the process of getting in is. So if everybody can see my screen. Yes. I'm going to go over there. I'm not logged into anything. This is on a computer that has been completely wiped. It's like, hey, you have an extension installed that you can't use. It knows that I have a GitHub pull request and issues extension. So that's why it's saying that. But obviously, I have never connected anything to Git. And I'm going to go ahead and just create a new R project here.
I'm not going to initialize with the Git repository. So I'm doing exactly what Isabella did. Just instead of an automated, like, create Quarto project, I'm just clicking through everything. All right. I'm heading over to that source control pane. Publish to GitHub is there for me. And Positron just knows that if you try to interact with GitHub and you're not logged in, that you need to authenticate. So I'm going to go ahead and do that. And I'm going to authenticate. So it gave me a little button to say, like, go ahead and copy this code. And when I go to authenticate, because it's opened my browser for me, it's just ready to paste in.
So I paste that in. I say, yep, I want this to authorize. Those are the associations that I have on GitHub. And I'm going to say, yep, authorize. And we're done. If you are used to setting things up in RStudio, you know that it's way harder than that. So this is pretty nice.
If you are used to setting things up in RStudio, you know that it's way harder than that. So this is pretty nice.
There we go. I'm going to go down and grant access through my GitHub account to the extension, the GitHub extension for pull requests and stuff. That's what you saw me do down there in that little accounts tab. So now you can see me creating a file here. And saving it. My source control tab can now, when I press this button, it knows that it's connected to me. And I can go ahead and publish an entire repository. And it's just going to open it up. I can click open in GitHub, and it's going to work. So that is the end of that. And we're going to actually go through that live, that part with Isabella now.
Staging, committing, and publishing to GitHub
Yeah. Thank you. Great question. All right. So going back here, we're going to go back to this source control item, where again, here are the files that we have changed, excluding the ones that I put in the Git ignore. And then if Git is new to you, generally the workflow is first you stage your changes, which lets Git know these have been changed. And they're the things that we're going to want to push up to our source of truth repository. And there's this plus sign where if I click that, it says stage all changes. You could do it individually as well. But since it's our first thing, I'm just going to say stage all changes. And you can see it's moved from changes to stage changes. So I know we're all set. I'm going to add a message. All right. Initial commit. Commit. And now, as Libby just shared, there's this publish branch option.
And branch are like the different offshoots of the things that you are working on. And down here in Positron, you can see which branch we're on, which is the main branch, which is like the real main branch. And Libby also has shared this cool snippet that you can put in your user settings so that the name of the branch also shows up at the top of your Positron window as well. So I have that because I do also find it very handy. I'm going to hit publish branch. It's going to let me have a couple of options to private or public repositories. Hitting public. Down here, it says successfully published the Quarto book to repository to GitHub. I'm going to open on GitHub.
And here we go. So we are in our repository. Here are all the files that we staged and committed and pushed up, which is great. And so since Libby and I are collaborating on this, I'm going to head over to settings and add Libby as a collaborator. So there is this collaborators option. And then clicking add people. I will find you, Libby.
Protecting the main branch
Okay. So it lets me know that we're awaiting Libby's response. But in the meantime, the next thing that I want to do is, so the main branch is, you know, it's the source of truth. It's the thing that's, you know, if it's a book, the thing that's being published and being shown. And so we generally want to protect it so that there is some sort of review process or at least some guardrails around what actually gets put on the main branch as people are working.
And so one way to protect the main branch is by clicking on branches here. Sorry, on settings. I'm going to click add classic branch protection rule. I'm going to write main to say I want to protect the main branch. And then here, I'm going to require a pull request before merging. So that means before I allow any changes to actually be made on the main branch, I'm going to require a pull request where I can review or, you know, my collaborators can review and somebody can, we can also check off this require approvals. So here, what I'm saying is at least one person needs to approve before the pull request can be merged and the main branch changed. So I'm going to create that.
And Libby, would you mind showing us from your side what it looks like to be added as a collaborator? Yes, I would love to. Also, Becca had asked, was that push to GitHub the initialization of the GitHub repo? Yes. If it was the creation, Becca says, what if you already had a GitHub repo with that same name, would you get a warning in Positron? I am not 100% sure what you would get as a warning in Positron. I think that there are so many different ways to do this. We are only showing one where like we don't have a remote repo set up with the GitHub website yet, right? If you did and it was already set up and it had stuff in it, the process would be you would clone it into Positron and you would just open it in Positron. So totally different workflow, but you'd get the same result of like a repo that was local now that was on your machine and it was hooked up to your remote repo in GitHub and Positron, the workflow in Positron would be the same from there on out.
To do clone in GitHub in Positron, it's very easy. Control shift P to get to the command palette and then just type the word clone and that's the first option you're going to see, get clone. And then it'll just ask you to type in or paste in the HTTPS if that's the way that you're going. I have that set up as my cloning option in the Positron settings. You can change it in the Positron settings to whatever you need.
So I have something waiting for me, or at least I should, in my notifications. You'll also get an email if somebody adds you as a collaborator. So I'm going to click this little thing right here. Oh, it says I'm all caught up. It says I do not have anything from Isabella. There it is. Oh, yay. Invitation to join DS Lab Quarto book. So if you click this, it's going to go away. Don't click that. It's going to say, ah, you're done with this message. You have to actually click the message and then accept the invitation, and that's going to make me a collaborator on this repo. That means that I can push to it. I cannot push to main, however, because, again, we protected the main branch of this repo, and we watched Isabella do that.
And Jordan mentioned, careful with branch rules and users who are admins. Some settings allow admins to bypass rules. There's a few extra clicks to make sure admins aren't excluded from the rules but can force push when needed. We'll actually show this a little bit later if we have time. I think with the rule that we set up, Isabella as an admin is actually not excluded. It's still going to make her get approval for a PR. She can click a button, an extra button on the UI in GitHub to push past that. So she can say, I am going to elect to push past this if she wants to. So good point, Jordan.
Creating and working on issues in Positron
So GitHub is the platform that we're using to use Git. And its icon is this, like, a little cat with a tentacle. And so if I click here, within Positron, there's these really cool, like, options to work with pull requests and issues directly within Positron, which blew my mind. I did not know this existed. I never clicked it before. So hopefully it blows your mind as well. Here in this window with issues, I'm going to create an issue by clicking this plus. And then I'm going to say, call it chapter one. And I'm going to, if you notice here, the first line will be the issue title. So the title of the issue will be chapter one. I'm going to tag Libby. And I'm going to write, you know, hey, Libby, some kind of description of the issue that I want. Could you please get started on chapter one? So once that's good, I save. And I hit this check. And it lets me know the issue has been created. If I open the issue, again, I can view this all within Positron. I can see that Libby has been assigned. And then here's my comment for Libby as well. And yeah, so now I pass it over to you to get started on chapter one.
Cloning the repo and attempting to push to main
Yeah. Okay. And pertinent to the question that we had before of like, how do I get it down if it's already existing? I'm in that situation now. It exists as this remote repo in GitHub in the UI right here for me. But I don't have it here. So I'm going to go grab the URL because the clone type I'm going to be using is HTTPS. And then over here, I can do command shift P, type in clone. It's going to ask me to provide the repository URL. There it is. Hit enter. And I'm going to say, sure, let's put it there.
And I'll open it in the same window. Do I trust the authors of this folder? Isabella, I don't know if I trust you. I'm going to say yes. Okay. And just like that, we're done. I have it open. My screen's going to look a little bit different from Isabella's because my activity bar is at the top here. I like this. It's so clean and nice, but I have all the same stuff, right? So here it's just smaller. Here's my little source control. And if I go over there, I can see that if I was going to make changes, they would end up there.
And this is where I can see that I have some issues open. My issue right here, I can go check it out. I can see that Isabella's asking me to get started on chapter one.
All right. So now what I should not do right now is go try to push to main. So let's do that. Because in real life, that's what I would forget and do. I would say, all right, she wanted me to get started on chapter one. So I need to create a new file. There's many ways to create a new file. I'm just going to do it like this and say chapter one.qmd. Great. This is chapter one. In true Libby fashion, let's leave a typo in there, and I will save it.
And the moment I save something, the source control says, you have something that we don't recognize. And there's a U here. You can see that it's an untracked file, right? If you hover over it, it'll say untracked. Let's head over to the source control tab. And it says, hey, you made a change. I can click this change. I can look at it. I can open the file here if I don't happen to have it open already. Like if I closed this and I click this, this would open it. I can revert my changes or I can stage it. If I have a bunch of changes, I can click this right here. It only shows up if you hover and it will just stage everything. So let's say stage. Great. And I'll say that I'm going to init chapter one and commit it and say, yeah, let's go ahead and push to main. And it tells me, hey, you're going to push and pull from main. Is that okay? And I say, yes. And then it says, wait, something is wrong. I'm going to hit that second one that said show command output. And it's going to tell me there's a protected branch. You cannot do that. You need to make changes through a pull request. And I'm like, oh, no, that's right. I should have made a branch.
Stashing changes and creating a branch
I'm unable to push to main. Okay. Cool. So what do I do if this is not three lines of code? What if this was a whole chapter that I had just done? In a past life, I would have literally copied and pasted this into a text file that I would have saved elsewhere and I would have absolutely panicked, right? Because I am never able to stash changes via the terminal correctly.
So let me just show you what I would do in this instance using the UI. First of all, I've already committed, right? All is not lost. Just like with the terminal, we can undo our last commit. So I'm going to go over here to this main branch here, and I'm going to go down to the commit, and I'm going to undo last commit. So again, three dots. There are three dots all over the place. You'll get to the right thing kind of no matter what here. Three dots, commit, undo last commit. And then I can breathe a sigh of relief because there it is. It's staged still, but it's not committed. Now what I'm going to do is go back to these and go down to stash and just say like, hey, can you just stash like the stage changes that I made? Just hold on to them.
Chapter one init changes. I'm going to hit enter. And now in the background, those are stashed away. It's kept my commit message, but they're gone. Now I can just say, okay, I'm definitely on the main branch. I can see that up here. Here it is. What I need to do is create a new branch. Normally in the terminal, I would get checkout or some other version of that. Again, you can just go down here to branch and create branch. Type in your branch name, chapter one branch. Great. Now I have those changes stashed somewhere.
This is swiped through, right? The reason this is swiped through is because if I go back over here, it doesn't exist. I stashed it. The changes that I made don't exist anywhere. They're like held off on the side for me. I want to now apply those changes to this, put that chapter one file back in there. We'll go back to our source control and I can go back to this little stash thing and I can say, pop stash. It's going to say, hey, which stash do you want to pop? I'm going to say this one. Cool. Now if I go back, it exists. There it is. It's been added. It's already staged for me. I can go back to my process, commit it. Now it's saying instead of sync, it's saying publish branch because this branch only exists for me locally. It doesn't exist remotely on Isabella's repo on the internet yet. I'll go ahead and publish my branch.
Creating a pull request from Positron
It says, hey, do you want to go ahead and create a pull request for this branch? I could, but I'm going to go back to the UI and just show you what it looks like when I refresh this. I refresh it and it says, hey, we now have two branches. It's ready to compare and do a pull request. You can do all of this from Positron though. You don't have to go back to the UI at all. What I'm going to do is I'm going to go ahead and create my pull request in Positron and I'm going to let Isabella know that I have created chapter one and I'm going to link it to that issue. We'll go back over here.
I could create a pull request right here, or I could just click this and create a pull request. I could also right in here, create a pull request. There's so many ways to do this, but we'll go back over here. We'll say the title of mine is init chapter one. In my description, I'm going to say this closes one because that's the issue that I know existed. Then it'll tell me my files changed. It shows me very clearly what I'm doing. I'm merging chapter one into main. Then I can also, if I hover over these, I can assign things and add reviewers. I want to add a reviewer. It knows who Isabella is. I'm going to click that little mark here and click okay. There she is as a reviewer.
If I scroll down, you can create right here. It's creating my pull request for me. I did not need to go to the UI. It's all just in Positron. Here's my pull request. We can switch back to Isabella so she can see what it looks like to check the update.
Everyone's okay, but there was, Danielle had a question about how to put your activity bar to the top. Maybe to show for the class because it's highly requested. Here's activity bar. It's that blue bar. If I right click and hit activity bar or hover over activity bar position, there will be several options. You could put it at the top like Libby has it. Libby, there's something about your settings end up up here. Yeah, they end up over here. When it's on the left, your account and your settings are in the bottom left. They silently retreat to the top right of your screen without telling you. If you've lost them because you've just done that, they're in the very top right.
Reviewing and merging the pull request
Libby has gone ahead and created a pull request. If I click this refresh pull request, now I can see all open pull requests and here is chapter one, which is great. I'm like, awesome. You'll notice that the branch protection policy must be fulfilled before merging, but I want to check out what was done first. I could do that by literally checking out. This checks out the branch, which up here used to be main and down here as well. It lets us know that right now I'm in the chapter dash one branch instead.
Lets me know, pulls up this file that is changes in the pull request. Green means that something has been added. Instead, let's say I just closed that, but I saw that there was indeed a typo. If I open up the files in my Explorer, open up chapter one, I'm like, oh no, I will fix this. I can go ahead and fix that typo. If you follow me on blue sky, this is normal.
There are so many little things that Positron does to let you know. For example, now the color has changed and you'll see that now there's this M. This lets us know that this file has been modified. We can see here too, a nice little view of what exactly has been modified as well.
Now I can see my chapter one has changed. Doing the same process as before, I can stage this change. When we move up to stage changes, I'll say fix typo, commit, and sync the changes. Let me know that it's pushing to chapter one, which is the right branch, and hit okay. Heading back to my pull request, I can open up this pull request again. I can see Libby's commit, my commit. I think we're all good now. I can say, thanks Libby.
From here, I can comment. You'll notice here, there's actually also an option for requesting changes if you don't want to approve, but because everything looks good now, I'm going to hit approve. Now, this is saying there's no conflicts with the base branch, which is main. I've approved the PR, but to actually bring the changes in, I have to merge the pull request. I'm going to do that.
If I scroll up here, it'll let me know that the pull request indeed has been merged. Then you'll notice that I have this option for deleting branch. This is another thing that you could set up one of those branch rules for to always delete your remote branches after a pull request, but because we don't have that rule set up right now, we can do it within Positron itself. If I hit delete branch, it'll give me the option to delete the remote branch. That's like the branch that's out in the internet, and then local branch, which is the copy that is on my personal laptop. If I hit delete branch, it'll give me the option that is on my personal laptop. Because we've merged this branch in, I don't need either of those anymore. I'm going to hit okay, and that's going to delete those branches. This is also really nice to keep your things tidy and remember what has been changed and merged and not.
Note, really quickly, because I'm watching this on my screen, I watched in real time, my Positron just alerted me that Isabella deleted that branch and closed that PR, which is very cool.
Note, really quickly, because I'm watching this on my screen, I watched in real time, my Positron just alerted me that Isabella deleted that branch and closed that PR, which is very cool.
And the last thing to mention is up here instead of Chapter 1, or down here as well, I'm back on main. And so, we have completed Chapter 1, and so if we go back to the Issues 2, you'll notice it's empty. And so, because Libby had written this closes number 1, it should delete that number 1 issue now because we've merged in the pull request. There are words that GitHub recognizes, closes is one of them, there's a whole list that you can go Google to do things inside of your issues, which is very cool.
Okay, so I told you that I watched that happen in real time. On my screen, what happened was all of these popped up, like, boop, boop, boop, boop, boop, and then I had this little toast message down here that said, like, hey, Isabella did some stuff. Now, she deleted her remote branch, the branch that lives in the cloud on the GitHub website. She also deleted her local branch, but that didn't delete it for me. I still have Chapter 1 branch, and I'm still on it, so I can still see Chapter 1 up here, and I can see Chapter 1 down here. So I can go up here and just very quickly be like, sweet, it's done, I'm going to delete my local branch, I'm done. That puts me back on main, and everything is cleaned up.
In a previous life, I would have been looking over here at my wall where I have a whole literal handwritten list of terminal commands for git. Don't judge me. I don't remember them. They fall out of my brain. But I would have gone over here and been like, cool, I probably need to prune deleted branches for my remote repo. I'm going to get fetch-p, and that's going to fetch for my main, it's going to prune any branches that I need to delete. But I don't have to do any of that. I'm so happy about that.
Collaborating on a second branch and handling merge conflicts
What I'm going to do is I'm going to create a Chapter 2 branch, and I'm going to ask Isabella to collaborate on it with me. Because I would love to show you what happens with merge commits, again, if GitHub has ever made you cry. It's probably a merge commit.
This is from Derek, that it's great that you can do all of these Git activities within Positron rather than out on the GitHub UI. Are there benefits to doing them within Positron or the GitHub UI? I think that not leaving the UI or not leaving the IDE, to me, is pretty great. I will say that there are certain things that you still have to go to the GitHub UI to do. For example, if Isabella did want to bypass that, sort of like, hey, I'm the admin, so let me just bypass this authorization for this pull request without getting an approval, you would have to go to the UI. There are very few things that you can't do from the IDE. I would say just having it all in one place is really helpful, because when you're in the IDE and you're literally getting alerts that things are happening, it means you can't miss them and mess stuff up, and that's really, really important.
Because if you've ever done something in GitHub or just a GitTrack project and you've messed it up, it's probably because you just didn't think to do the stuff like, oh, I need to pull before I make any changes, I need to see if anyone has done anything. So if you're collaborating in real time, having that real-time input, to me, is just invaluable. But yeah, it's up to you. If you really, really like the GitHub UI, stick with it. We're just trying to show you what's possible in case you've never seen it before.
I'm going to go through the process of just creating a branch again. There are so many ways to do this. Again, I could go to Command-Shift-P and do stuff. I could say Git Branch, and it's going to be like, cool, what do you want to do? I'm going to say, oh, I want to create a branch, and I want to name it Chapter 2. And there we go. I don't even have to click anything, so that's just another way to do it.
I'm going to go create a Chapter 2, and instead of doing New File, again, I could go over here and say New File, right? It knows I want to create a Quarto document. I could say, let's save it and call it Chapter 2.qmd, and let's just say Chapter 2. If you know how Quarto books work at all, you'll know that we're not actually adding it to the metadata, to the .yaml here, therefore it's not going to show up if we render it. This is just for illustration purposes. We're just going to create some files and collaborate on them in Git.
So now it says, I know that this exists. I know that we're on the Chapter 2 branch. All is good. I'm going to go ahead and initialize Chapter 2, and I'm going to go ahead and commit it.
Do you know how to delete a branch if it's an older rogue branch? This is from Amiko. If you have an older branch, how can you get the UI to delete it? Yeah. If you have an older rogue branch, you mean like in here? Locally. I think it should still show up. Would you go to delete branch? So if you go here? Yeah. I think the three dots give you the delete branch option if you scroll down. So you can either do it here where you type in branch, and it's going to be smart enough to give you all the options of what you can do. If you want to delete a branch, it's going to find every Git tracked branch for your project and give you the option, and it'll give you a little checkboxes next to them. So if I said delete branch, it's going to give me right now options that I don't want. But if you had any tucked away in that project, they would be there.
So I forgot to stage these. There we go. We're staged. Can we init Chapter 2? Yes. Can we publish our branch? Yes. I don't want to create a pull request, but I do want to create an issue. So I'm going to go over here and go to issues, and there's a little plus button. So I could do that. That opens up a markdown file for me to create an issue, or I could also go over to my actual files, and I could do something like to do initialize Chapter 2.
And you'll notice that Positron is smart enough to recognize this word. And in the Positron settings, there is a whole list of words like issue, like to do, that it will recognize, and it'll give you this little light bulb. And it'll say, oh, it looks like you want to create a GitHub issue. And I'll be like, yes, I do. I want to call it initialize Chapter 2. And I press enter, and I'm done. Issue created.
I'm going to go over here and go to issues, and I'm going to use this to create my Let's collab on chapter two. These are comments. They're not going to show up. It's just giving you instructions. If I want to assign it to somebody, I think it pops up if I actually use my at. There we go. I'm so smart. Use your at symbol, y'all. There we go. And then I'm not going to label it, give it to a milestone or a project. I'm just going to add things here. Great. Now the issue has been created. Again, it's always going to give you the option to look at it. Here's the assignee.
Learning Git and GitHub
While we're swapping, we've got two questions in the Discord. One is from Jeff. Is the functionality similar if you're working with an internal organization like Azure DevOps or a version of Git? I have never used these Azure DevOps. I assume it's the same, but I don't know if either of y'all have experience with this. I don't. I have only ever used straight up GitHub, and I've also never used GitLab or SVN. So this is where I would hope that there are some people in the chat who have worked with Azure DevOps. If you have, please let us know how it goes and come back to the chat and help answer that question.
When people are interested, Mike raised the question, what is the best way to get orientation into the world of Git and GitHub? We've got happy Git with R. We have a few software carpentries ideas. But do you have any other suggestions about how to learn about Git? My biggest suggestion is to use it. And so what I would do is get with a person who is in the community, who's at work with you, who can start a Git project with you, and then do something completely low stakes. You could literally just open text files and text back and forth to each other. This is what I do with students to teach them Git. So instead of opening code files, maybe they're .R files, but just open a .txt file, add a line that's a message to somebody like, hey, what's going on? Commit that. They can get it. They can modify it. They can add another line to add another little text. And they're like, it's going great. How about you? Right? And send that back. Something low stakes like that that's not going to make you cry is a great idea to get used to Git.
And then working with somebody who's used to it. Honestly, I think that using a UI like this where you can point and click stuff and you are 100% relying on the terminal to do stuff that is more complex is really, really helpful. And then I would also, if you happen to be somebody who's at an organization where you're working with mono repos that contain multiple projects inside of a repo, I would Google GitHub, well, WorkTrees inside of VS Code or inside of Positron. WorkTrees, I think, is all one word. We're not going to show that today. We have 10 minutes left.
And what Isabella is going to do is pull my changes and respond to my issue. I can see, indeed, there are two issues. And just on that note, I totally agree. I learned how to use Git and GitHub by collaborating on projects that didn't need Git and GitHub just to build that muscle. And when I finally got a job that did need it, you know, it was old hat.
Pulling changes and syncing branches
So I go back to the GitHub icon and I can see, indeed, I have two issues. Going back to my files, you'll notice that I am on the main branch. But right now, I don't see chapter one. And the reason is my local version of the repository and the one that's remote, you know, in GitHub, are not synchronized. And so I want to make sure that my main branch is always synchronized.
So to do that, I can go to source control. Clicking these three buttons by source control lets you open up repositories. And then I can see this is my DSLabQuartoBook repository. And then you'll notice like the circle arrow icon lets me know that there are three commits that from the origin main, the GitHub version of this project, that I can pull down. It's down at the bottom left, too. So it's trying to remind you at the bottom as well. It's like main little recycled symbol and three. Yeah. It's like, there are changes. Please do something. And so clicking that, it'll let me know. It'll pull from origin main. Clicking OK. Going back to my files. Now I can see, indeed, I have chapter one where I didn't before.
Going back to source control, I can click here. And this is another option for branches, which allows me to see all the branches. Oh, I think I need to synchronize first, right, Libby? I think so. You'll have to pull down. So this like pulls down not just the changes from main, but everything else that's going on, you know, in the internet. So hopefully now if I click this button, I can see that there is this chapter two branch that I can check out and work from. Clicking this, now I am in the chapter two branch, indeed. And opening it up, now there's this chapter two. And let's say we're collaborating. I want to continue adding to this book. I'm going to say it's going to be great. I'm going to save. I'm going to stage. I'm going to write a message. Commit. And changes. And so now this is pushing those changes to the chapter two branch.
Simulating a merge conflict and resolving it
In the six minutes we have left, I would really love to just simulate the most true version of my experience of Git, which is me messing stuff up. And how you fix it in the Positron ecosystem here. Okay. So I created chapter two. I pushed that. Isabella did the right thing. And she pulled it down. And she made some changes. And she pushed those changes back to the chapter two branch. What if I don't do that? What if I don't pull my changes down? Right? What if I don't pull, which is right here? And I don't fetch anything from my remotes? Let's just go change this. Let's just be reckless.
I'm going to go over here and be like, ah-ha-ha. I am so silly. Not going to pull or anything. And now I'm going to save this. Cool. I'll stage it. And I'll say also continuing chapter two. But the wrong way. Bam. I committed it. I'm on chapter two. I'm like double checking everything. I'm like, yes, I'm doing everything I should. And it's like, hey, do you want to push and pull to chapter two? Yeah, sure, let's do that. And it says, um, I don't know if you want to do that. Show command output. Oh, no. Oh, no. This is where I start crying. I'm like, hello, fatal. The word fatal? Are you kidding me? It's terrifying.
Clearly I have made some mistakes here. So what can we do? First of all, we can undo our last commit.
