Up and Running with Git Transcripts
Chapter: Teamwork: Branches
Lecture: Feature now in place

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's look at one more idea, One more workflow for branching and this is going to be feature branches.
0:08 We've got a new idea for our app and it's going to take a little bit of work. We're not sure exactly when we're going to be finished with it.
0:16 So we don't want to hold up release of new features. We want to branch off, do a bunch of work there and when it's ready
0:22 we're going to merge that back. So remember that's working a new feature. Make a bunch of changes, think about when it's time to bring it in and
0:30 then bring that back in with emerge. That's what we got on deck for this one. So here we are back in our rock paper scissors.
0:39 Let's suppose that we want to make it add some little bit of idiosyncrasy to our computer role. Now this is the way the computer chooses.
0:51 It just goes to all the role names. Rock, paper scissors, spock and lizard, and it just randomly picks one evenly.
0:58 But let's give it a little bit of weirdness that if people know like a little
1:01 inside game or they could even observe it that there's something odd about the computer.
1:06 It really likes things that start with the word S so it might play scissors and Spock more frequently than paper, lizard or rock.
1:16 Okay, so let's go and say we want to add that feature, but other stuff is going to go along. Maybe that's really kind of complicated.
1:22 We're not sure. So I could just start changing here on main, but everyone else on, the team is going to have to see that.
1:29 And if there's no team, it may still destabilize our app for other things we might do to it may be a bug fix comes on and we've got a real
1:36 quick make a change or something like that. Alright, so we're going to create what's called a feature branch now again,
1:45 we can do this anywhere. I'm going to do this over on GIT hub, create a branch here to start and then go from there.
1:52 So I'm just going to say however things are at the moment, I want to just create a new branch. This will be feature or one thing you can do.
2:01 That's kind of cool. If you put like your initials or something and a slash and we go um feature biased computer,
2:12 something like that. We create a branch from there. I'll show you this has a neat little effect.
2:18 So we've created this branch. Were separated from the main development things can go on So let me just give you an example.
2:24 For for example, like if we say, oh we added new features as part of like some other flow of the development working
2:32 forward on main. This is not going to be affected for us, we're not going to see it and so on. Uh and we won't also affect it.
2:42 So work will be able to continue on forward. Kind of like that completely trivial thing. I just did. So we want to check that out again.
2:51 We could do that in VS. Code, we could do that in source tree. We go back to our PS and fetch.
3:01 Well see now on remote, this is the thing I wanted to show you, check this out now. You have all of your branches.
3:08 If you do MK/, well I do that from Michael Kennedy. You can see that all of my stuff gets put into little folders and source tree
3:16 So you could have like bugs/features/your name /whatever. You can sort of leverage that to do this. Cool branching stuff if you want.
3:26 So I can check it out here but let's just check it out in PyCharms You can see down here we have these and this one I'm done with right
3:34 maybe. So I could come down here and delete this and it says do you want to delete the tracked branch?
3:40 No that is like effectively unchecking it out locally but it doesn't delete it from another repository. I could always go back and check it out again.
3:50 Okay, so I'm going to check out this one. This this one the feature biased computer notice it went back to the way it was
4:01 when we and that initial branch. And let's just quick knock something out here. Let's see I got some ideas.
4:12 Re factor, extract the method so that we can say get computer a role. So we got this and then down here somewhere.
4:22 Yeah. Computer roles. We have our role names. And let's just, I can do variable. This will be Rolls her name's is fine.
4:35 But let's let's do this. Let's say it's twice as likely to play anything with the S. So we've got all the role names and we want to add
4:45 the list of our for r enroll names. Role names. If r.starts with S. Okay. So let's just put a quick break point right here just to see that
5:00 this is doing what we might expect. I don't care about whatever that is. I'm going to play number four. What's the computer gonna do? Check this out.
5:08 It plays rock, paper scissors, lizard, Spock. That's the real names but the names are the same and then scissors appears again and spock appears again.
5:19 So there's twice as likely to play scissors. Spock as they are. Anything else? It's not the best high performance way to do things.
5:27 But you know what? It's gonna work just fine. So let's play a little bit of this here. You know what I know they're going to play speaking.
5:36 Let me remind myself what defeats Spock. Spock is defeated by lizard and paper. Alright let's let's throw a lot of lizard in here.
5:46 Alright. You roll lizard. They roll scissors of course. And sadly in a gruesome way the lizard is defeated. Let's do it again. Who surprise,
5:56 surprise they rolled Spock. we're going to keep just going. They played lizard. Ah still tied, still tied. They played scissors.
6:07 Oh I wasn't counting on scissors. They played so well. You can see they're playing the S.S
6:11 a little bit more. And finally for the first time in this entire course I've crushed them 3-2. Well crushing. That's not exactly what that would be.
6:21 But I did beat them. Super cool. So now we can say we can say biased role in place and if I commit
6:29 and push that, where is it going to go to this biased branch. Great. And we can come up here. Let's look here in our rps. You have fetched sync it up.
6:45 We're on the MK/feature branch and now see the bias roles in place over there. But the main or gmain and local main,
6:54 it's totally fine. Right? So you are a path to one is forward. So everything's looking good. Let's just make one more change.
7:01 Remember in my example of the feature branches we had multiple steps. What else do we want to do?
7:07 Let's have it just print, I don't want to change this line actually. So we can do maybe just a print down here biased towards the s -- hint hint.
7:26 This is pretty contrived but when it plays, you can say five and you can see computer bias towards the s hint hint.
7:35 I just want to show a couple of changes to like more work on feature here push those forward and if we do a fetch just to refresh the history and
7:50 that's why we could close it and open it again as well. So you can see more work on the feature going down that path.
7:57 And then let's say we want to remove the logging, remove the logging oops. Once we select the changes there,
8:12 that's it. Our feature. Let's consider this. Complete there we have it. We've got the bias role in place.
8:23 We did some logging. We're happy we removed the logging. So I think our feature is complete but it's not yet coordinated or organized,
8:31 synced back into or delivered to the actual app. Right? It's this sort of exploratory thing.

Talk Python's Mastodon Michael Kennedy's Mastodon