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