Effective PyCharm Transcripts
Chapter: Source control
Lecture: Branching

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


Talk Python's Mastodon Michael Kennedy's Mastodon