Up and Running with Git Transcripts
Chapter: Teamwork: Branches
Lecture: Next: Fix the bug

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