Effective PyCharm Transcripts
Chapter: Source control
0:00 The next thing I want to focus on is branching.
0:03 Now, if branching is a concept that's new to you,
0:06 it allows for parallel development within source code.
0:11 ideas you can create one branch, one area where people are working and putting their code
0:15 emerging and then another where people can continue to work with different,
0:19 possibly incomplete or breaking changes and then often ideas at some point they're going to be
0:24 brought back together once both sets of changes are made.
0:28 A really common way that this might be done is we might have a feature request
0:32 and instead of trying to add the feature directly to the main branch,
0:35 which will put likely the software into some incomplete state where we couldn't ship it to
0:41 production, we'll work in a second branch and then we're already we're gonna bring those
0:46 back over often in what's called a poor request.
0:49 So I wanna take you through that flow as a way of teaching about how
0:54 PyCharm work with branches. So you learn a little bit about this,
0:56 git flow stuff as well. So what we're gonna do is we're gonna go over
0:58 here, I'm going to create an issue for a moment and this is going to
1:02 be ad version to header, title display.
1:06 This is not important enough really to justify this whatsoever,
1:10 but here's an idea. We want the app version in the header.
1:16 Okay, we had that little talk python podcast downloaded thing.
1:19 Well we wanted to say version 2.1 or something so I'll go ahead and assign this
1:23 to myself. It doesn't really matter.
1:25 But let's go ahead and create it.
1:27 Why did I create this issue?
1:28 Because this is super common around adding features of software.
1:33 We're going to have an issue then we have a branch where we develop those changes
1:36 to that issue and then we're gonna put that branch back in the main so we'll
1:39 go quite through that flow. So I'm gonna go create a branch like this,
1:44 we'll just say version to header and the number is 48 that's the issue number.
1:48 So let's go back to the code here and I'm going to go say we want
1:54 Version to header with some dashes here.
1:59 I'm going to put the issue name for my version branch.
2:01 I'll put the issue names will create this branch and let's go back over into PyCharm
2:06 So here we are. And we want to make a change,
2:10 we want to say like version 2.1 or whatever.
2:13 We don't have those changes. We just made on the server.
2:16 And if you go down here on the right this section right here,
2:19 this little branch, this is where all the branch magic in PyCharm lives and
2:23 it's really, really useful so we can see the remote branches.
2:26 The local branches. If there's a new remote one,
2:28 I could check it out but I already have it checked out here.
2:31 So there's not a lot going on but I want to go and get the new
2:35 ones. So just like getting new code,
2:36 we can click this update project.
2:39 And then now down here we have our feature branch version to header,
2:43 issue 48. But notice it's not in our local branches so I'm going to go
2:48 and check this out now. It looks the same because we created a branch off
2:53 of what we were working on before.
2:55 But down here notice we're now on this particular branch but we can go and add
3:00 our feature. What version is this going to be?
3:03 Well let's say it's 2.1 and let's even go farther.
3:06 We'll actually put a little version maybe even version you got one down into the section
3:17 We can actually print it out like this.
3:21 Make that an F. String.
3:22 Perfect. Let's test our code all there it is.
3:25 I see there's some amazing stuff up here.
3:28 We've got our version but notice we could probably use a few more dashes so let's
3:33 put that in there, see that we're happy the feature.
3:36 Oh it looks pretty good. Now we go I think that's pretty close clean up
3:41 the code so we're really happy with it and now we're going to commit this back
3:46 into github so we're gonna committed to this version branch.
3:51 I'm gonna go over here and I'm gonna actually say this issue fixes the issue.
3:54 What issue is it? Well I was very careful to choose my branch to have
3:59 the issue name so that always saves me from going and checking what I'm working on
4:03 So this fixes number 48.
4:05 Ad version to title. We can go ahead and commit and push that straight to
4:10 github. It's going to push to the branch that we care about.
4:14 Wait for it committed. Go back to our project.
4:17 You can see the color of our program is back now just because we made the
4:23 changes to this branch that didn't change the main thing.
4:25 So let's go over here and switch back to our ref.
4:29 And I notice it's back without the version.
4:32 You also get this workspace dialog.
4:35 So this workspace basically the shape of these windows which Windows was open and all that
4:40 kind of stuff. They are associated with that branch.
4:42 And if you go to another branch and reconfigure out everything what looks and you switch
4:46 between the branches. You can have PyCharm basically adapt to the different workflows and
4:53 if you come down here and even configure it to say show me the notification each
4:56 time. I don't want to see the notification.
4:58 I'm fine that it does the switch but I don't need to be told about it
5:01 every single time. So there it should be quiet when we switch between our branches