Up and Running with Git Transcripts
Chapter: Teamwork: Branches
Lecture: Next: Fix the bug
0:00 So of course we want a branch from here and I can do that. I can right click and say branch. It will allow us to create a new branch based on this,
0:09 what's called a shot. This is the hash of where that committee is, where we've tagged it and it will create it here.
0:17 But I want to do something slightly different. I want to do it over on github. Let's go over here to github. I want to do it on github for two reasons.
0:26 One to show you here's a cool way to start out on the server so everyone gets access to it straight away. The other one is there's a problem.
0:34 So let's go down here. We can see our tags. Hmm that's unfortunate. There's only V1 tag here And it looks like maybe I need to refresh it, nope,
0:46 there really is only V1 tag. But in this we have 2 I was quick, I didn't mean to forget to push it up to the remote server but I did
0:57 So let's just go and fix that real quick. So this tag, I could keep this tag locally until I'm sure I want to make it part of the official repository.
1:05 But when you create a tag you don't have to start on the server. But now I want to push to origin, wait for it refresh. Cool.
1:16 Now our tags are in sync with a server so let's go back over here and I want to go To tag click on V1 and then in this section this
1:27 is sort of where you manage branching. I can say I want to create a new branch. Let's call this depending on what you wanna,
1:33 how you wanna think about it, you might want to call this like some kind of bug fix and then tag the
1:38 results. So I'll say um bug no input validation and sometimes you might even want to have an issue over here that has a number.
1:50 So you might say 342 or 372 which might be the bug number. But I'm just gonna leave it like this,
1:55 create a branch from here. So this branch is now separate from our other one Let's go and we'll get the changes again.
2:05 We'll do a pull now here we have origin bug no input validation. So that means over on git hub.
2:12 This is where this branch is currently and it's just in sync with that step but soon it'll sort of sidestep and do something different.
2:20 Right? And here is where origin main is. So what we want to do is we've got these origin branches,
2:27 we want to check them out so I can go here and say check out. Let's do it in PyCharm though.
2:35 Command T to update the project just to make sure it's seen the changes probably it has from what we did in source tree,
2:42 you could say either merge or re base. I always use merge once you tell it don't ask again and guess what?
2:48 It won't ask again. So we can come down here just like we did before and here's the no input validation. Check that out now. We have it locally.
2:58 Okay, so let's go and fix that terrible bug. So the problem is when we run it, let's just put seven Index out of range, I can just click right here,
3:08 it'll jump us right to it. So here's the problem. We get the selected index, we let them enter 123 but in Python it's 012 in the um dictionary or the
3:18 list here. So all we really need to do is a quick check. So we can say if selected index is less than zero or greater than equal to
3:33 the length of role names. That's the problem. We want to print Yeah. Whoops, that's out of bounds and we'll just return nothing.
3:45 Let's see if this fixes the problem. Let's make sure it still works. three Great. We rolled scissors. That's what we intended, 74.
3:54 Whoops. That's out of bounds. Try again. I think we fixed it. So our bug is fixed. Let's commit.
4:03 Our changes. Just do that in a PyCharm and the editor fixed bug. We'll put the 372 just kind of uh you put a number to actually link
4:13 over in Github. It's not really a thing because we don't have that many bugs but that's how you would do it fixed bug.
4:19 For input validation, commit and push notice. It's going to push to origin bug no input validation. Not back to main. Fantastic.
4:32 Let's over here and look on. Git hub. Never mind this pull request stuff we'll get to in a minute. It says this branch is a little bit of a head,
4:42 this is the bug fix and also behind that's the five way rock paper scissors. That's fine. So we have these different branches now for V1 and V2.